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

Conversion results unreliable for array schemas in formData parameters with multipart/form-data content type #199

Open
2 tasks done
ghost opened this issue Sep 4, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2019

When in an OpenAPIv2 file, an operation contains a parameter in: formData that has an array schema and the request's body is specified to have Content-Type: multipart/form-data, the Mermade produced OpenAPIv3 equivalent ignores the collectionFormat property. It has been stated in

Until this is fixed, the Mermade converter should signal an error "don't know how to convert in:formData parameter with array schema in Content-Type: multipart/form-data".

Checklist

  • Conversion: I have checked my source definition is valid OpenAPI 2.0
  • Conversion: On valid OpenAPI 2.0 input, the conversion looks wrong

Detailed Description

Assume an operation with Content-Type: multipart/form-data.

In OpenAPIv2 the serialization of parameters that have an array schema is guided by the collectionFormat property.

In OpenAPIv3, on the other hand, such parameters are first-level properties in the schema of the mediaType of the content of the requestBody.
The important sections here in the OpenAPIv3 spec https://github.com/OAI/OpenAPI-Specification/blob/676b48d8385244d5b02a9cfe40059d4a41f329cc/versions/3.0.2.md are:

In particular, the serialization is specified through an encoding object outside the schema object, but in this object the properties style and explode are ignored for Content-Type: multipart/form-data.

I have prepared 4 test cases.

$ swagger2openapi -o form-multipart-parameter-array-of-strings-csv.v3m.json form-multipart-parameter-array-of-strings-csv.v2.json
$ swagger2openapi -o form-multipart-parameter-array-of-strings-ssv.v3m.json form-multipart-parameter-array-of-strings-ssv.v2.json
{ S2OError: collectionFormat:ssv is no longer supported except for in:query parameters
    at throwError (/openapi/node_modules/swagger2openapi/index.js:39:15)
    at throwOrWarn (/openapi/node_modules/swagger2openapi/index.js:54:9)
    at processParameter (/openapi/node_modules/swagger2openapi/index.js:564:21)
    at processPaths (/openapi/node_modules/swagger2openapi/index.js:936:30)
    at main (/openapi/node_modules/swagger2openapi/index.js:1170:5)
    at /openapi/node_modules/swagger2openapi/index.js:1505:13 name: 'S2OError' }
$ swagger2openapi -o form-multipart-parameter-array-of-strings-pipes.v3m.json form-multipart-parameter-array-of-strings-pipes.v2.json
{ S2OError: collectionFormat:pipes is no longer supported except for in:query parameters
    at throwError (/openapi/node_modules/swagger2openapi/index.js:39:15)
    at throwOrWarn (/openapi/node_modules/swagger2openapi/index.js:54:9)
    at processParameter (/openapi/node_modules/swagger2openapi/index.js:572:21)
    at processPaths (/openapi/node_modules/swagger2openapi/index.js:936:30)
    at main (/openapi/node_modules/swagger2openapi/index.js:1170:5)
    at /openapi/node_modules/swagger2openapi/index.js:1505:13 name: 'S2OError' }
$ swagger2openapi -o form-multipart-parameter-array-of-strings-multi.v3m.json form-multipart-parameter-array-of-strings-multi.v2.json

All should provide the same error message.

Other stuff

Version: swagger2openapi-5.3.0

form-multipart-parameter-array-of-strings-csv.v2.json.gz
form-multipart-parameter-array-of-strings-ssv.v2.json.gz
form-multipart-parameter-array-of-strings-pipes.v2.json.gz
form-multipart-parameter-array-of-strings-multi.v2.json.gz

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

0 participants