We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We try to update from OpenAPI 3.0 to 3.1 and face the issue that enums fromValue method behave different now
fromValue
the enum type has nullable: true set. With openapi 3.0.3 this is generated:
nullable: true
@JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } return null; }
when changing to 3.1.0 the null is not supported anymore:
@JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } throw new IllegalArgumentException("Unexpected value '" + value + "'"); }
I'm not aware of any way to change that.
7.11.0
openapi: 3.1.0 info: title: Minimal API Example version: 1.0.0 paths: /items: get: summary: Get items responses: '200': description: A list of items content: application/json: schema: type: array items: $ref: '#/components/schemas/Item' components: schemas: Item: type: object properties: name: type: string status: $ref: '#/components/schemas/StatusEnum' StatusEnum: type: string nullable: true enum: - available - out_of_stock - discontinued
openapi-generator generate -g java --library webclient -i example.yaml
grep fromValue -A10 ./src/main/java/org/openapitools/client/model/StatusEnum.java
The text was updated successfully, but these errors were encountered:
I found out that nullable is not a thing anymore and hence dropped when parsing with swagger-parser.
nullable
The alternative is pointed out here: OAI/OpenAPI-Specification#2244 (comment)
Instead of nullable:true, change the type type: [string, 'null']
nullable:true
type: [string, 'null']
Sorry, something went wrong.
No branches or pull requests
Bug Report Checklist
Description
We try to update from OpenAPI 3.0 to 3.1 and face the issue that enums
fromValue
method behave different nowthe enum type has
nullable: true
set.With openapi 3.0.3 this is generated:
when changing to 3.1.0 the null is not supported anymore:
I'm not aware of any way to change that.
openapi-generator version
7.11.0
OpenAPI declaration file content or url
Generation Details
openapi-generator generate -g java --library webclient -i example.yaml
Steps to reproduce
grep fromValue -A10 ./src/main/java/org/openapitools/client/model/StatusEnum.java
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: