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

Breaking changes in kin-openapi v0.124.0 - change of type definition #149

Open
grokify opened this issue Apr 7, 2024 · 5 comments
Open

Comments

@grokify
Copy link
Owner

grokify commented Apr 7, 2024

From go test. Appears that Types has changed types to github.com/getkin/kin-openapi/openapi3.Types from string:

openapi3/visit.go:29:5: cannot use propRef.Value.Type (variable of type *"github.com/getkin/kin-openapi/openapi3".Types) as string value in argument to visitTypeFormat
openapi3/visit.go:41:4: cannot use paramRef.Value.Schema.Value.Type (variable of type *"github.com/getkin/kin-openapi/openapi3".Types) as string value in argument to visitTypeFormat
openapi3/visit.go:59:6: cannot use paramRef.Value.Schema.Value.Type (variable of type *"github.com/getkin/kin-openapi/openapi3".Types) as string value in argument to visitTypeFormat
@grokify grokify changed the title Breaking changes in kin-openapi v0.124.0 - change of map definitions Breaking changes in kin-openapi v0.124.0 - change of type definition Apr 7, 2024
@grokify
Copy link
Owner Author

grokify commented Apr 7, 2024

Definition for github.com/getkin/kin-openapi/openapi3.Types is here:

https://pkg.go.dev/github.com/getkin/[email protected]/openapi3#Types

Definition for Schema.Type is as follows:

v0.124.0

Type         *Types       `json:"type,omitempty" yaml:"type,omitempty"`

Types is a []string:

type Types []string

https://pkg.go.dev/github.com/getkin/[email protected]/openapi3#Schema

v0.123.0

Type         string        `json:"type,omitempty" yaml:"type,omitempty"`

https://pkg.go.dev/github.com/getkin/[email protected]/openapi3#Schema

@grokify
Copy link
Owner Author

grokify commented Apr 15, 2024

Spec discussion:

getkin/kin-openapi#563

In OpenAPIv3.0 type can only take a single string value per https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#properties

In OAS 3.0.3:

https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#properties

The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification.

  • type - Value MUST be a string. Multiple types via an array are not supported.

This is no longer the case in OAS 3.1.0.

This issue:

getkin/kin-openapi#563

Mentions this YAML impelmentation:

'Legal in v2':
  type: [boolean, string]

'Legal in v3.0':
  oneOf:
  - {type: boolean}
  - {type: string}

@grokify
Copy link
Owner Author

grokify commented Apr 15, 2024

It is best to validate that downstream tools like OpenAPI Generator, Docusaurus, Redoc and others behave as expected given use of oneOf.

@grokify
Copy link
Owner Author

grokify commented Jun 16, 2024

oapi-codegen PR changes for reference: https://github.com/oapi-codegen/oapi-codegen/pull/1532/files

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

No branches or pull requests

1 participant