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
We would like to use org.bson.types.ObjectId type to reference elements in an array:
BulkUpdateErpOrderNumberDto:
type: objectdescription: List of replenishment process IDs for which a new ERP order number should be setproperties:
erpOrderNumber:
type: stringmaxLength: 50description: SAP (ERP) order numberexample: ERP58207rpIds:
type: arrayuniqueItems: trueminItems: 1items:
$ref: '#/components/schemas/ObjectId'description: Replenishment process IDsexample: [ 662760d01aad920e6773c164, 662762491aad920e6773c166 ]required:
- rpIds# Mapped to the Mongo ObjectId objectObjectId:
type: objectdescription: ObjectId valueexample: 64a55f3ad5804f0f591b9375
The problem is that generated code tries to validate external mapped types. The generated code can't be compiled because org.bson.types.ObjectId can't be validated (Set<@Valid org.bson.types.ObjectId>)
@Schema(name = "BulkUpdateErpOrderNumberDto", description = "List of replenishment process IDs for which a new ERP order number should be set")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.6.0")
publicclassBulkUpdateErpOrderNumberDto {
privateStringerpOrderNumber;
@ValidprivateSet<@Validorg.bson.types.ObjectId> rpIds = newLinkedHashSet<>();
publicBulkUpdateErpOrderNumberDto() {
super();
}
/** * Constructor with only required parameters */publicBulkUpdateErpOrderNumberDto(Set<@Validorg.bson.types.ObjectId> rpIds) {
this.rpIds = rpIds;
}
}
@Valid annotation shouldn't be added when object is mapped in pom.xml file.
Note that if refer ObjectId with objectId like this:
[WARNING] Unknown type found in the schema: objectId. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)
But generated code is correct:
@Schema(name = "BulkUpdateErpOrderNumberDto", description = "List of replenishment process IDs for which a new ERP order number should be set")
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.6.0")
publicclassBulkUpdateErpOrderNumberDto {
privateStringerpOrderNumber;
@ValidprivateSet<org.bson.types.ObjectId> rpIds = newLinkedHashSet<>();
publicBulkUpdateErpOrderNumberDto() {
super();
}
/** * Constructor with only required parameters */publicBulkUpdateErpOrderNumberDto(Set<org.bson.types.ObjectId> rpIds) {
this.rpIds = rpIds;
}
}
Of course the OpenAPI specification is not valid
The text was updated successfully, but these errors were encountered:
Description
We use Maven openAPI generator plugin version 7.6.0 with following settings:
We would like to use
org.bson.types.ObjectId
type to reference elements in an array:The problem is that generated code tries to validate external mapped types. The generated code can't be compiled because
org.bson.types.ObjectId
can't be validated (Set<@Valid org.bson.types.ObjectId>
)@Valid
annotation shouldn't be added when object is mapped inpom.xml
file.Note that if refer
ObjectId
withobjectId
like this:It works with a warning:
But generated code is correct:
Of course the OpenAPI specification is not valid
![Screenshot 2024-06-24 at 14 32 34](https://private-user-images.githubusercontent.com/2969871/342321290-e7a1d773-d9a4-448f-aeba-8f58196ffbdf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwNDM1NTksIm5iZiI6MTcyMDA0MzI1OSwicGF0aCI6Ii8yOTY5ODcxLzM0MjMyMTI5MC1lN2ExZDc3My1kOWE0LTQ0OGYtYWViYS04ZjU4MTk2ZmZiZGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDNUMjE0NzM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjRhODEyNDc4NTNkMThmNjYzYTA2ODM3NjlmMzcyNmVjMDA0NDg2NzJmNjY0Mzk3NTg1NmVhM2UwMDVlYWQ0OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.pyylvg1bASOQfeJ9u40YluLloz7SYoRjN8oohT0Dcbc)
The text was updated successfully, but these errors were encountered: