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