Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Problem with multipart-multifile post-body #43

Open
tuxedo0801 opened this issue Jul 25, 2018 · 2 comments
Open

Problem with multipart-multifile post-body #43

tuxedo0801 opened this issue Jul 25, 2018 · 2 comments

Comments

@tuxedo0801
Copy link

tuxedo0801 commented Jul 25, 2018

After creating the code for nodejs I tried to start the project by npm start in the out-folder.

But I get an error message:

API Errors:

  #/paths/~1task~1/post/parameters/0: Not a valid parameter definition
    #/paths/~1task~1/post/parameters/0: Not a valid parameter definition
      #: Missing required property: schema
      #: Not a valid undefined definition
        #/type: No enum match for: object
        #/type: No enum match for: object
        #/type: No enum match for: object
        #/type: No enum match for: object
    #/paths/~1task~1/post/parameters/0: Missing required property: $ref

1 error and 0 warnings

The corresponding yaml-part:

  /task:
    post:
      tags:
        - app
      summary: create task
      operationId: createTask
      description: |
        todo
      responses:
        '200':
          description: OK
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                offerNumber: # metadata part
                  description: 'todo'
                  type: string
                trayImages: # image part
                  type: array
                  items:
                    type: string
                    format: base64
              required:
                - offerNumber
                - trayImages
            encoding:
              trayImages: 
                contentType: image/png, image/jpeg
        required: true

The idea behind this: The POST request must contain a kind of meta-data (the "offernumber"), and at least one image file. The number of images is not specified. It depends on how much the client wants to pass to the server.

See also: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#special-considerations-for-multipart-content

The API was designed with help of swaggerhub. And swagger-hub does not show me any error.

Can someone tell me what's wrong with my API?

@tuxedo0801
Copy link
Author

@MikeRalphson Any idea? Is this a bug? Or is the yaml wrong?

@MikeRalphson
Copy link
Contributor

The underlying issue is that the nodejs code generation is just a very thin wrapper around swagger-tools and swagger-tools only supports OAS 2.0. For that reason, your input OAS 3.0.x document has to be down-converted to OAS 2.0 and of course, not everything that can be expressed in OAS 3 can be expressed in OAS 2.0.

At the moment I'm not sure if the downconverter can be modified to make swagger-tools do the right thing when given your input OAS document. I'll have to brush up on whether OAS 2.0 supported arrays of file parameters...

In the meantime, it might be worth looking at something like https://github.com/exegesis-js/exegesis for node.js support of OAS 3, though we don't have a code-gen template for it, nor do I know if one would really be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants