[BUG][JAVA] required on component only set on the getter of the model
Created by: wvtbg
We have a post method with a component as body. This component has required field but sending a post with missing elements is allowed with the current generated code. openapi yaml : ... paths: /events: post: tags: - Event Data operationId: createEvent requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/event' ... components: schemas: event: title: event description: event type: object required: - eventName properties: eventName: type: string
pom.xml ... org.openapitools openapi-generator-maven-plugin 6.0.1 spring-boot-api generate spring true true true false spring-boot ...
event class generated : ... @JsonProperty("eventName") private String eventName; ... @NotNull @Schema(name = "eventName", required = true) public String getEventName() { return eventName; }
public void setEventName(String eventName) { this.eventName = eventName; }
--
We expect the @NotNull on the setter to or even on the Property. Now we can call the create without any content in the body except '{}'