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

Fallback to interface{} in case a type cannot be determined #73

Closed
weitzj opened this issue Oct 18, 2019 · 0 comments
Closed

Fallback to interface{} in case a type cannot be determined #73

weitzj opened this issue Oct 18, 2019 · 0 comments

Comments

@weitzj
Copy link
Contributor

weitzj commented Oct 18, 2019

In some weird OpenAPI specs, it is possible that you might have an array defined, but no items.
In the current implementation of oapi-codegen, this leads to a nullpointer-exception (NPE).

It would be better, if we could just fallback to an interface type. This way the generated Go-Code is fine and will compile, and it will be up to the user of the generated Go-Library to cast/map the interface{} to the appropiate Go-struct. It should not be a concern that the openapi-spec is crap, as long as we have interface{} available as a placeholder.

weitzj pushed a commit to devk-insurance/oapi-codegen that referenced this issue Oct 18, 2019
This adds a fallback behaviour in case a type cannot
be determined, where one should be expected.

This is for example the case if one defines a type `array`
but does not add any `items` definitions to it.

Fixes:

- oapi-codegen#73
adrianpk pushed a commit to foorester/oapi-codegen that referenced this issue Jan 16, 2024
…api-codegen#74)

This adds a fallback behaviour in case a type cannot
be determined, where one should be expected.

This is for example the case if one defines a type `array`
but does not add any `items` definitions to it.

Fixes:

- oapi-codegen#73
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

1 participant