You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When a schema is extended, using allOf, and some constraints are applied to the properties of the original object, but the constraints are inserted above the reference to the original schema; the constraints are not applied in the generated code. Whereas, the swagger UI seems to render the schemas correctly.
openApiGenerate {
generatorName.set("spring")
inputSpec.set("$projectDir/src/main/resources/openapi.yaml")
outputDir.set("$buildDir/generated")
apiPackage.set("com.myname.prjname.api")
modelPackage.set("com.myname.prjname.model")
configOptions.set(
mapOf(
"library" to "spring-boot",
"useSpringBoot3" to "true",
"language" to "Kotlin",
"interfaceOnly" to "true",
"useTags" to "true",
"useOperationId" to "true"
)
)
typeMappings.set(
mapOf(
"Page" to "org.springframework.data.domain.Page",
"Pageable" to "org.springframework.data.domain.Pageable",
"Sort" to "org.springframework.data.domain.Sort",
"PageGardenInfo" to "org.springframework.data.domain.Page<com.myname.prjname.model.GardenInfo>",
"PagePlantOffer" to "org.springframework.data.domain.Page<com.myname.prjname.model.PlantOffer>",
"PagePlantedPlant" to "org.springframework.data.domain.Page<com.myname.prjname.model.PlantedPlant>",
"PageGardener" to "org.springframework.data.domain.Page<com.myname.prjname.model.Gardener>"
)
)
}
Steps to reproduce
1 - Create a schema with some non-required properties.
2 - Create another schema, using the allOf construct, that extends the first one.
3 - Add some constraints to the properties from the previous schema, listing above the reference to the previous schema.
Suggest a fix
Instead of iterating over the schemas and applying the constraints as they come, store them in a secondary location and apply them all at the end.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When a schema is extended, using allOf, and some constraints are applied to the properties of the original object, but the constraints are inserted above the reference to the original schema; the constraints are not applied in the generated code. Whereas, the swagger UI seems to render the schemas correctly.
openapi-generator version
version "7.12.0"
OpenAPI declaration file content or url
Expected vs Actual Output
Expected:
public class PlantOfferCreateRequest {
private String name;
private String imageURL;
private Integer averageDaysToHarvest;
private Price price;
private Long gardenId;
}
Actual:
public class PlantOfferCreateRequest {
private @nullable String name;
private @nullable String imageURL;
private @nullable Integer averageDaysToHarvest;
private @nullable Price price;
private Long gardenId;
}
Generation Details
The gradle plugin configuration:
Steps to reproduce
1 - Create a schema with some non-required properties.
2 - Create another schema, using the allOf construct, that extends the first one.
3 - Add some constraints to the properties from the previous schema, listing above the reference to the previous schema.
Suggest a fix
Instead of iterating over the schemas and applying the constraints as they come, store them in a secondary location and apply them all at the end.
The text was updated successfully, but these errors were encountered: