[BUG][Java Spring OAS3] Deprecated @Schema(required) annotation property is generated
Created by: whydoievenneedthis
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output?
Description
When using the spring generator, the fields in the generated POJOs are annotated with @Schema(required = true | false)
, which is now deprecated. Instead, the requiredMode
should be used.
openapi-generator version
6.2.1
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Api Documentation
description: Api Documentation
termsOfService: urn:tos
contact: {}
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0
version: '1.0'
paths: {}
components:
schemas:
ResponseEntry:
type: object
required:
- id
properties:
id:
type: string
format: uuid
name:
type: string
Actual output
Something along the lines of:
@NotNull @Valid
@Schema(name = "id", required = true)
@JsonProperty("id")
private UUID id;
@Schema(name = "name", required = false)
@JsonProperty("name")
private String name;
Expected output
Something along the lines of:
@NotNull @Valid
@Schema(name = "id", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("id")
private UUID id;
@Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) // or .AUTO, here I'm not sure which would be better
@JsonProperty("name")
private String name;
Suggest a fix
Update the pojo.mustache file (plus anything that might be using the same annotation property).