Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14398
Closed
Open
Issue created Jan 06, 2023 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

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

Assignee
Assign to
Time tracking