Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG][javascript-flowtyped] Flow check error (node.js) #7382

Closed
5 tasks done
zole40 opened this issue Sep 9, 2020 · 1 comment · Fixed by #7786
Closed
5 tasks done

[BUG][javascript-flowtyped] Flow check error (node.js) #7382

zole40 opened this issue Sep 9, 2020 · 1 comment · Fixed by #7786

Comments

@zole40
Copy link
Contributor

zole40 commented Sep 9, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

I found the following problem in the generated code when tried to run the flow check:

Cannot delete localVarUrlObj.search because undefined [1] is incompatible with null [2]. [incompatible-type]

     openapi/src/api.js
   
              localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
                 // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
 [1]              delete localVarUrlObj.search;
           localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
      
                 return {

     /private/tmp/flow/flowlib_34e1ce2/node.js
 [2] 2191│     search: string | null,

openapi-generator version: 4.3.1
OpenAPI declaration file content or url
openapi: '3.0.3'
info:
  version: 0.1.0
  title: Test
servers:
  - url: /api
tags:
  - name: test
    description: |
paths:
  /dummy:
    get:
      summary:  Dummy endpoint.
      operationId: dummy
      tags:
        - simulation
      description: |
        Dummy endpoint.
      responses:
        '200':
          description: Success call
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DummySuccess'
        default:
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DummyError'

components:
  schemas:
    DummySuccess:
      type: string
      example: ok
    DummyError:
      properties:
        errorMassage:
          type: string
          example: error
Generation Details
  • generatorName = "javascript-flowtyped"
Steps to reproduce
  • run generator javascript-flowtyped
  • run flow check
Related issues/PRs
Suggest a fix

Change this line delete localVarUrlObj.search; to this localVarUrlObj.search = null; It could solve the flow issue. It is seen to be ok, but I did not test it all possibilities yet.

@wing328
Copy link
Member

wing328 commented Sep 9, 2020

@zole40 thanks for reporting the issue. I wonder if you can file a PR with the suggested fix so that we can review it more easily.

thSoft added a commit to thSoft/openapi-generator that referenced this issue Oct 19, 2020
thSoft added a commit to thSoft/openapi-generator that referenced this issue Oct 21, 2020
wing328 pushed a commit that referenced this issue Oct 26, 2020
* [javascript-flowtyped] Fix Flow error (#7382)

Fix deletion of search field

* [javascript-flowtyped] Regenerate sampe (#7382)
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants