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

[BUG][Java Spring OAS3] Deprecated @Schema(required) annotation property is generated #14398

Closed
5 tasks done
whydoievenneedthis opened this issue Jan 6, 2023 · 1 comment
Closed
5 tasks done

Comments

@whydoievenneedthis
Copy link

whydoievenneedthis commented Jan 6, 2023

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).

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

2 participants