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
  • #13885
Closed
Open
Issue created Nov 02, 2022 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][JAVA] Bug generating @NotNull when useBeanValidation is set to false

Created by: codarsan

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

We encountered an issue with the spring generator (we use open api gradle plugin) When we try to upgrade to 6.2.1, the generator seems to generate @NotNull annotations from javax Validation even though we have the config useBeanValidation set to false.

openapi-generator version

It is a regression in 6.2.1

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Management
  version: 1.0.0
paths:
  /service:
    get:
      operationId: save
      responses:
        200:
          description: done
          content:
            application/json;charset=utf-8:
              schema:
                type: string
components:
  schemas:
    Request:
      type: object
      required:
        - 'requiredParam'
        - 'requiredParam2'
      properties:
        requiredParam:
          type: string
        requiredParam2:
          type: string
        optionalParam:
          type: string
Generation Details
  • org.openapi.generator version "6.2.1"
  • spring generator
  • with configOptions = [ openApiNullable : "false", interfaceOnly : "true", useBeanValidation: "false", dateLibrary : "java8" ]
Steps to reproduce

Create a gradle project with configuration

task generateOpenApi(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = "spring"
    inputSpec = "$rootDir/src/main/resources/api/server/management.yml"
    outputDir = "$buildDir/generated/openApi"
    apiPackage = "com.application.api"
    modelPackage = "com.application.model"
    typeMappings = [
            OffsetDateTime: 'java.time.LocalDateTime'
    ]
    configOptions = [
            openApiNullable  : "false",
            interfaceOnly    : "true",
            useBeanValidation: "false",
            dateLibrary      : "java8"
    ]
    generateApiTests = false
    generateModelTests = false
}

Open the generated file Request.java

Related issues/PRs

I did not find any.

Observation

Even though the @NotNull annotations are generated, I noticed that the imports are missing so the generated code doesn't compile.

Assignee
Assign to
Time tracking