Package dk.mada.jaxrs.openapi
Class TypeConverter
java.lang.Object
dk.mada.jaxrs.openapi.TypeConverter
Converts a specification schema to an internal model type.
-
Constructor Summary
ConstructorDescriptionTypeConverter
(TypeNames typeNames, ParserTypes parserTypes, ParserTypeRefs parserRefs, Naming naming, ParserOpts parserOpts, Parser.LeakedGeneratorOpts leakedGenOpts) Constructs a new type converter. -
Method Summary
Modifier and TypeMethodDescriptionCreates a DTO from an Object schema.createMultipartDto
(String groupOpId, io.swagger.v3.oas.models.media.Schema schema) Creates a synthetic DTO for passing multipart form parameters.reference
(io.swagger.v3.oas.models.media.Schema<?> schema, @Nullable String propertyName, @Nullable String parentDtoName, boolean isFormRef) Converts a OpenApi schema to parser type reference.toReference
(io.swagger.v3.oas.models.media.Schema<?> schema) Converts a OpenApi schema to an internal model type.toReference
(io.swagger.v3.oas.models.media.Schema<?> schema, boolean required) Creates the schema reference, but overrides the required state.
-
Constructor Details
-
TypeConverter
public TypeConverter(TypeNames typeNames, ParserTypes parserTypes, ParserTypeRefs parserRefs, Naming naming, ParserOpts parserOpts, Parser.LeakedGeneratorOpts leakedGenOpts) Constructs a new type converter. This operated by looking up types, creating if missing, in the types instance.- Parameters:
typeNames
- the type namesparserTypes
- the parser typesparserRefs
- the parser referencesnaming
- the naming instanceparserOpts
- the parser optionsleakedGenOpts
- the leaked generator options
-
-
Method Details
-
toReference
Converts a OpenApi schema to an internal model type.- Parameters:
schema
- the OpenApi schema to convert- Returns:
- the found/created internal model type
-
toReference
Creates the schema reference, but overrides the required state. This is used from parameters, where the required property comes from the parameter.- Parameters:
schema
- the OpenApi schema to convertrequired
- the required value to override in the reference- Returns:
- the found/created internal model type
-
reference
public ParserTypeRef reference(io.swagger.v3.oas.models.media.Schema<?> schema, @Nullable String propertyName, @Nullable String parentDtoName, boolean isFormRef) Converts a OpenApi schema to parser type reference. This serves as a lazy reference to something that will eventually be resolved to a type in the model.- Parameters:
schema
- the OpenApi schema to convertpropertyName
- the name of the property the type is associated with, or nullparentDtoName
- the name of the DTO this schema is part of, or nullisFormRef
- true if the reference is a form parameter/field.- Returns:
- the found/created parser type reference
-
createMultipartDto
public ParserTypeRef createMultipartDto(String groupOpId, io.swagger.v3.oas.models.media.Schema schema) Creates a synthetic DTO for passing multipart form parameters. The name is controlled by the name of the method needing the DTO.- Parameters:
groupOpId
- the group-operationid of the parent resource methodschema
- the schema of the DTO- Returns:
- a reference to the created DTO
-
createDto
Creates a DTO from an Object schema.- Parameters:
dtoName
- the DTO nameschema
- the schema of the DTO- Returns:
- the create DTO
-