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

Null output for formData parameter #28

Closed
MinniArora opened this issue Jun 18, 2020 · 5 comments
Closed

Null output for formData parameter #28

MinniArora opened this issue Jun 18, 2020 · 5 comments
Labels

Comments

@MinniArora
Copy link

Hi
Defining parameter as below gives null on running swagger brake:

{"in":"formData","name":"fileName","description":"fileName","required":true,"schema":{"type":"string"}}

Output:
Successfully loaded APIs
Starting the check for breaking API changes
null
For help please use --help

Is there anything missing?

@galovics
Copy link
Member

@MinniArora could you please provide a full Swagger that could be used to repro the issue? That would speed up the investigation for sure. Thanks!

@MinniArora
Copy link
Author

MinniArora commented Jun 19, 2020

@galovics Sure. PFA.
swagger-brake-issue.zip

@galovics
Copy link
Member

Hi @MinniArora. I've checked the attached definition, thanks for that.
It seems like you are not conforming the OpenAPI specification. Your API definition is using the 2.0 version. In that case according to the specification:

schema is only used with in: body parameters. Any other parameters expect a primitive type, such as type: string, or an array of primitives.

Your API definition when using formData (like for access_token), you are specifying a schema. If you flatten it and change it to a primitive string type, its going to work.

For OpenAPI V3, the formData attribute concept has been replaced with relying on the requestBody attribute of a path. In that case, the way to define it is to always use a schema:

In OpenAPI 3.0, form data is modelled using a type: object schema where the object properties represent the form fields

I think your definition is between the 2 versions. Although I'm going to introduce some level of validation to detect the wrong usage of the schema attribute.

@MinniArora
Copy link
Author

@galovics Thank you for a detailed reply. This swagger file is auto generated using springfox. Came across this

@galovics
Copy link
Member

@MinniArora got it, then thats the reason.

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

No branches or pull requests

2 participants