OpenAPITools / OpenAPITools/openapi-generator
[BUG][Regression] ImportMappings Do not work in V6.5.0
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The use of importMapping no longer works with v6.5.0 spring generator.
The generated code uses List<@Valid Tag> where Tag is absolute reference to a class.
This is not compatible with the @Valid annotation.
openapi-generator version
v6.5.0 worked in v6.4.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Computation Services Common
description:Computation Services Common
version: 1.0.0
paths: { }
components:
schemas:
MeshAnalysisParams:
type: object
properties:
satellites:
$ref: '#/components/schemas/Satellites'
zoneOfInterest:
$ref: 'model.yaml#/components/schemas/ZoneOfInterest'
splitConstraint:
$ref: 'model.yaml#/components/schemas/SplitConstraint'
MeshAnalysisResponse:
type: object
properties:
acqrs:
type: array
items:
$ref: '#/components/schemas/MeshByAcqR'
DtoAnalysisParams:
type: object
properties:
satellites:
$ref: '#/components/schemas/Satellites'
period:
$ref: 'model.yaml#/components/schemas/DateTimePeriod'
meshesByAcqR:
type: array
items:
$ref: '#/components/schemas/MeshByAcqR'
solarAngleThreshold:
type: number
format: double
skyBrightnessThreshold:
type: number
format: double
depointingConstraint:
$ref: 'model.yaml#/components/schemas/DepointingConstraint'
DtoAnalysisParamsInstance:
type: object
properties:
satellite:
description: The name of the satellite.
example: SAT1
type: string
period:
$ref: 'model.yaml#/components/schemas/DateTimePeriod'
meshesByAcqR:
type: array
items:
$ref: '#/components/schemas/MeshByAcqR'
solarAngleThreshold:
type: number
format: double
skyBrightnessThreshold:
type: number
format: double
depointingConstraint:
$ref: 'model.yaml#/components/schemas/DepointingConstraint'
DtoAnalysisResponse:
type: object
properties:
dtosByAcqR:
type: array
items:
$ref: '#/components/schemas/DtoByAcqR'
MeshByAcqR:
type: object
properties:
idAcqR:
type: string
description: "Id of the AcqR"
meshes:
type: array
items:
$ref: 'model.yaml#/components/schemas/Mesh'
DtoByAcqR:
type: object
properties:
idAcqR:
type: string
description: "Id of the AcqR"
dtos:
type: array
items:
$ref: 'model.yaml#/components/schemas/Dto'
Satellites:
description: The names of the satellites.
example: [SAT1, SAT2]
type: array
items:
type: string
OrbitData:
type: object
properties:
satName:
type: string
period:
$ref: 'model.yaml#/components/schemas/DateTimePeriod'
OrbitInfo:
type: object
properties:
pos:
type: array
items:
$ref: '#/components/schemas/OrbitPosition'
OrbitPosition:
type: object
properties:
latitude:
type: number
format: double
longitude:
type: number
format: double
altitude:
type: number
format: double
SatelliteEphemerisPeriodResponse:
type: object
properties:
satellite:
type: string
description: Name of the satellite
example: SAT1
period:
$ref: 'model.yaml#/components/schemas/DateTimePeriod'
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.5.0</version>
<executions>
<execution>
<id>generate-server</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/target/generate-api/common.yaml</inputSpec>
<generatorName>spring</generatorName>
<generateSupportingFiles>true</generateSupportingFiles>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<modelNamePrefix>Rest</modelNamePrefix>
<configHelp>false</configHelp>
<verbose>false</verbose>
<configOptions>
<delegatePattern>true</delegatePattern>
<java8>true</java8>
<dateLibrary>java8-localdatetime</dateLibrary>
<basePackage>package.mus.computation.common</basePackage>
<modelPackage>package.mus.computation.common.model</modelPackage>
<apiPackage>package.mus.computation.common.api</apiPackage>
<configPackage>package.mus.computation.common.config</configPackage>
<useOptional>false</useOptional>
<hateoas>false</hateoas>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
<schemaMappings>
<importMapping>DateTimePeriod=package.commons.api.model.RestDateTimePeriod
</importMapping>
<importMapping>UserOrder=package.commons.api.model.RestUserOrder</importMapping>
<importMapping>ProgR=package.commons.api.model.RestProgR</importMapping>
<importMapping>ZoneOfInterest=package.commons.api.model.RestZoneOfInterest
</importMapping>
<importMapping>SplitConstraint=package.commons.api.model.RestSplitConstraint
</importMapping>
<importMapping>
DepointingConstraint=package.commons.api.model.RestDepointingConstraint
</importMapping>
<importMapping>
DepointingConstraintElevation=package.commons.api.model.RestDepointingConstraintElevation
</importMapping>
<importMapping>
DepointingConstraintRollPitch=package.commons.api.model.RestDepointingConstraintRollPitch
</importMapping>
<importMapping>AcqR=package.commons.api.model.RestAcqR</importMapping>
<importMapping>Mesh=package.commons.api.model.RestMesh</importMapping>
<importMapping>Dto=package.commons.api.model.RestDto</importMapping>
<importMapping>Dtoe=package.commons.api.model.RestDtoe</importMapping>
<importMapping>MeshPoint=package.commons.api.model.RestMeshPoint</importMapping>
</schemaMappings>
</configuration>
</execution>
<execution>
<id>generate-doc</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/target/generate-api/common.yaml</inputSpec>
<generatorName>dynamic-html</generatorName>
<configHelp>false</configHelp>
<output>${project.build.directory}/generated-docs/openapi/</output>
</configuration>
</execution>
</executions>
</plugin>
package package.mus.computation.common.model;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.ArrayList;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import jakarta.annotation.Generated;
/**
* RestMeshByAcqR
*/
@JsonTypeName("MeshByAcqR")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2023-04-19T12:26:04.392255300+02:00[Europe/Paris]")
public class RestMeshByAcqR {
private String idAcqR;
@Valid
private List<@Valid package.commons.api.model.RestMesh> meshes;
public RestMeshByAcqR idAcqR(String idAcqR) {
this.idAcqR = idAcqR;
return this;
}
/**
* Id of the AcqR
* @return idAcqR
*/
@Schema(name = "idAcqR", description = "Id of the AcqR", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("idAcqR")
public String getIdAcqR() {
return idAcqR;
}
public void setIdAcqR(String idAcqR) {
this.idAcqR = idAcqR;
}
public RestMeshByAcqR meshes(List<@Valid package.commons.api.model.RestMesh> meshes) {
this.meshes = meshes;
return this;
}
public RestMeshByAcqR addMeshesItem(package.commons.api.model.RestMesh meshesItem) {
if (this.meshes == null) {
this.meshes = new ArrayList<>();
}
this.meshes.add(meshesItem);
return this;
}
/**
* Get meshes
* @return meshes
*/
@Valid
@Schema(name = "meshes", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("meshes")
public List<@Valid package.commons.api.model.RestMesh> getMeshes() {
return meshes;
}
public void setMeshes(List<@Valid package.commons.api.model.RestMesh> meshes) {
this.meshes = meshes;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RestMeshByAcqR meshByAcqR = (RestMeshByAcqR) o;
return Objects.equals(this.idAcqR, meshByAcqR.idAcqR) &&
Objects.equals(this.meshes, meshByAcqR.meshes);
}
@Override
public int hashCode() {
return Objects.hash(idAcqR, meshes);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class RestMeshByAcqR {\n");
sb.append(" idAcqR: ").append(toIndentedString(idAcqR)).append("\n");
sb.append(" meshes: ").append(toIndentedString(meshes)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Jakarta validation does not accept private List<@Valid package.commons.api.model.RestMesh> meshes;
Generation Details
Steps to reproduce
Related issues/PRs
Introduced by issue #14959
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Maven plugin configuration, the OpenAPI declaration, and the generated RestMeshByAcqR.java shown in the report; compare generation with v6.4.0 and v6.5.0. Trace how schemaMappings/importMapping are applied to array item types, then verify that generated Java uses a valid imported type without the fully qualified type-use annotation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100