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
I'm encountering an issue when parsing OpenAPI 2.0 specifications with non-body parameters (e.g., path, query, header parameters) using the kin-openapi library.
According to the OpenAPI 2.0 specification, parameters are defined as either bodyParameter or nonBodyParameter. Both should be handled during unmarshalling. Non-body parameters, such as those located in the path or query string, should be parsed correctly into types like string, number, or array.
However it seems that the kin-openapi library currently only implements parsing for bodyParameter types. The openapi2.Parameter struct uses the Type *openapi3.Types field, which doesn’t account for the type field in non-body parameters.
Actual Behavior
The unmarshalling process fails when non-body parameters are encountered. This is likely because the library expects a schema field in all parameters (as required by body parameters) but fails to account for non-body parameters that define their type with the type field instead.
Currently, the kin-openapi library only seems to handle the bodyParameter case, which includes a schema field. The non-body parameters rely on fields like type, in, and required, but the library attempts to parse them as body parameters, causing an error.
Steps to Reproduce
Here’s a simple test case to reproduce this issue:
I encountered the same issue on those non-body parameters under a path cannot be unmarshaled with a 2.0 spec.
There seem to be no other packages that could convert v2 to v3 spec, so this issue here is quite crucial IMO.
I'm encountering an issue when parsing OpenAPI 2.0 specifications with non-body parameters (e.g., path, query, header parameters) using the
kin-openapi
library.Unmarshalling a OpenAPI 2.0 spec to an openapi2.T instance fails for non-body parameters like the ones in this spec: https://raw.githubusercontent.com/tcorman/pubstest/master/cpqapiv2.yaml.
Expected Behavior
According to the OpenAPI 2.0 specification, parameters are defined as either
bodyParameter
ornonBodyParameter
. Both should be handled during unmarshalling. Non-body parameters, such as those located in the path or query string, should be parsed correctly into types likestring
,number
, orarray
.However it seems that the
kin-openapi
library currently only implements parsing forbodyParameter
types. Theopenapi2.Parameter
struct uses theType *openapi3.Types
field, which doesn’t account for thetype
field in non-body parameters.Actual Behavior
The unmarshalling process fails when non-body parameters are encountered. This is likely because the library expects a
schema
field in all parameters (as required by body parameters) but fails to account for non-body parameters that define their type with thetype
field instead.Here’s an excerpt from the OpenAPI 2.0 schema:
Currently, the
kin-openapi
library only seems to handle thebodyParameter
case, which includes aschema
field. The non-body parameters rely on fields liketype
,in
, andrequired
, but the library attempts to parse them as body parameters, causing an error.Steps to Reproduce
Here’s a simple test case to reproduce this issue:
Error Message
The following error occurs when attempting to unmarshal non-body parameters in the spec:
Relevant Links
The text was updated successfully, but these errors were encountered: