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
ConstructorsConstructorDescriptionTypeConverter(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, @Nullable ContentSelector.ContentContext context) 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.toReferenceFromApi(io.swagger.v3.oas.models.media.Schema<?> schema, ContentSelector.ContentContext context) 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.- 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
-
toReferenceFromApi
public ParserTypeRef toReferenceFromApi(io.swagger.v3.oas.models.media.Schema<?> schema, ContentSelector.ContentContext context) 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 convertcontext- the context of 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, @Nullable ContentSelector.ContentContext context) 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.context- the content context, or null- 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
-