You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: application/x-www-form-urlencoded, the Mermade produced OpenAPIv3 equivalent is wrong in the following cases:
no collectionFormat specified,
collectionFormat: csv,
collectionFormat: ssv,
collectionFormat: pipes.
The result is only correct when collectionFormat: multi is specified.
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: application/x-www-form-urlencoded.
In OpenAPIv2 the serialization of parameters that have an array schema is guided by the collectionFormat property.
In particular, the serialization is specified through an encoding object outside the schema object, and in this object the properties style and explode have the same meaning as for query parameters. Namely:
collectionFormat:csv (or absent collectionFormat) corresponds to style:form explode:false.
collectionFormat:ssv corresponds to style:spaceDelimited.
collectionFormat:pipes corresponds to style:pipeDelimited.
collectionFormat:multi corresponds to style:form explode:true.
Additionally, note that the default style is form, and for style: form, default explode is true.
Here the correct result is form-url-parameter-array-of-strings-csv.v3.json. 'style:form' may be omitted, but 'explode:false' is essential.
$ swagger2openapi -o form-url-parameter-array-of-strings-ssv.v3m.json form-url-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' }
Here no error should be signalled. The correct result is form-url-parameter-array-of-strings-ssv.v3.json. 'style:spaceDelimited' is essential.
$ swagger2openapi -o form-url-parameter-array-of-strings-pipes.v3m.json form-url-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' }
Here no error should be signalled. The correct result is form-url-parameter-array-of-strings-pipes.v3.json. 'style:pipeDelimited' is essential.
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 haveContent-Type: application/x-www-form-urlencoded
, the Mermade produced OpenAPIv3 equivalent is wrong in the following cases:collectionFormat
specified,collectionFormat: csv
,collectionFormat: ssv
,collectionFormat: pipes
.The result is only correct when
collectionFormat: multi
is specified.Checklist
Detailed Description
Assume an operation with
Content-Type: application/x-www-form-urlencoded
.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 theschema
object, and in this object the propertiesstyle
andexplode
have the same meaning as for query parameters. Namely:collectionFormat:csv
(or absentcollectionFormat
) corresponds tostyle:form explode:false
.collectionFormat:ssv
corresponds tostyle:spaceDelimited
.collectionFormat:pipes
corresponds tostyle:pipeDelimited
.collectionFormat:multi
corresponds tostyle:form explode:true
.Additionally, note that the default style is
form
, and forstyle: form
, default explode istrue
.I have prepared 5 test cases.
Here the correct result is form-url-parameter-array-of-strings-default.v3.json. 'style:form' may be omitted, but 'explode:false' is essential.
Here the correct result is form-url-parameter-array-of-strings-csv.v3.json. 'style:form' may be omitted, but 'explode:false' is essential.
Here no error should be signalled. The correct result is form-url-parameter-array-of-strings-ssv.v3.json. 'style:spaceDelimited' is essential.
Here no error should be signalled. The correct result is form-url-parameter-array-of-strings-pipes.v3.json. 'style:pipeDelimited' is essential.
Here the result is correct; it is equivalent to form-url-parameter-array-of-strings-multi.v3.json.
Other stuff
Version: swagger2openapi-5.3.0
form-url-parameter-array-of-strings-default.v2.json.gz
form-url-parameter-array-of-strings-default.v3.json.gz
form-url-parameter-array-of-strings-csv.v2.json.gz
form-url-parameter-array-of-strings-csv.v3.json.gz
form-url-parameter-array-of-strings-ssv.v2.json.gz
form-url-parameter-array-of-strings-ssv.v3.json.gz
form-url-parameter-array-of-strings-pipes.v2.json.gz
form-url-parameter-array-of-strings-pipes.v3.json.gz
form-url-parameter-array-of-strings-multi.v2.json.gz
form-url-parameter-array-of-strings-multi.v3.json.gz
The text was updated successfully, but these errors were encountered: