Class Swagger2Module
- java.lang.Object
-
- com.github.victools.jsonschema.module.swagger2.Swagger2Module
-
-
Constructor Summary
Constructors Constructor Description Swagger2Module()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyToConfigBuilder(SchemaGeneratorConfigBuilder builder)protected BooleancheckNullable(MemberScope<?,?> member)Determine whether the given field/method may be null based on@Schema(nullable = true).protected booleancheckReadOnly(MemberScope<?,?> member)Determine whether the given field/method is deemed read-only based on@Schema(accessMode = AccessMode.READ_ONLY).protected booleancheckRequired(MemberScope<?,?> member)Determine whether the given field/method is deemed required in its containing type based on@Schema(required = true).protected booleancheckWriteOnly(MemberScope<?,?> member)Determine whether the given field/method is deemed write-only based on@Schema(accessMode = AccessMode.WRITE_ONLY).protected TypemapAdditionalPropertiesEnumValue(io.swagger.v3.oas.annotations.media.Schema annotation)Derive the allowed type of a schema's additional properties from the given annotation.protected voidoverrideInstanceAttributes(com.fasterxml.jackson.databind.node.ObjectNode memberAttributes, MemberScope<?,?> member, SchemaGenerationContext context)Consider various remaining aspects.protected CustomPropertyDefinitionprovideCustomSchemaDefinition(MemberScope<?,?> scope, SchemaGenerationContext context)Implementation of theCustomPropertyDefinitionProviderto consider external references given in@Schema(ref = ...).protected IntegerresolveArrayMaxItems(MemberScope<?,?> member)Determine the given field/method'sArraySchemaannotation is present and contains a specificmaxItems.protected IntegerresolveArrayMinItems(MemberScope<?,?> member)Determine the given field/method'sArraySchemaannotation is present and contains a specificminItems.protected BooleanresolveArrayUniqueItems(MemberScope<?,?> member)Determine the given field/method'sArraySchemaannotation is present and is marked asuniqueItems = true.protected StringresolveDefault(MemberScope<?,?> member)Look-up the default value for the given field/method from@Schema(defaultValue = ...).protected StringresolveDescription(MemberScope<?,?> member)Look-up description from@Schema(description = ...)for given field/method.protected List<String>resolveEnum(MemberScope<?,?> member)Look-up the finite list of possible values from@Schema(allowableValues = ...).protected BigDecimalresolveExclusiveMaximum(MemberScope<?,?> member)Look-up the exclusive maximum value from@Schema(maximum = ..., exclusiveMaxium = true)for the given field/method.protected BigDecimalresolveExclusiveMinimum(MemberScope<?,?> member)Look-up the exclusive minimum value from@Schema(minimum = ..., exclusiveMinium = true)for the given field/method.protected StringresolveFormat(MemberScope<?,?> member)Look-up the value from@Schema(format = ...)for the given field/method.protected BigDecimalresolveInclusiveMaximum(MemberScope<?,?> member)Look-up the inclusive maximum value from@Schema(maximum = ..., exclusiveMaxium = false)for the given field/method.protected BigDecimalresolveInclusiveMinimum(MemberScope<?,?> member)Look-up the inclusive minimum value from@Schema(minimum = ..., exclusiveMinium = false)for the given field/method.protected IntegerresolveMaxLength(MemberScope<?,?> member)Look-up the value from@Schema(maxLength = ...)for the given field/method.protected IntegerresolveMinLength(MemberScope<?,?> member)Look-up the value from@Schema(minLength = ...)for the given field/method.protected BigDecimalresolveMultipleOf(MemberScope<?,?> member)Look-up the value from@Schema(multipleOf = ...)for the given field/method.protected StringresolvePattern(MemberScope<?,?> member)Look-up the value from@Schema(pattern = ...)for the given field/method.protected StringresolvePropertyNameOverride(MemberScope<?,?> member)Determine an alternative name for the given field/method, based on@Schema(name = ...).protected List<com.fasterxml.classmate.ResolvedType>resolveTargetTypeOverrides(MemberScope<?,?> member)Derive target type override from@Schema(implementation = ...).protected StringresolveTitle(MemberScope<?,?> member)Look-up title from@Schema(title = ...)for given field/method.protected booleanshouldBeIgnored(MemberScope<?,?> member)Determine whether the given field/method should be skipped, based on@Schema(hidden = true).
-
-
-
Method Detail
-
applyToConfigBuilder
public void applyToConfigBuilder(SchemaGeneratorConfigBuilder builder)
- Specified by:
applyToConfigBuilderin interfaceModule
-
resolveTargetTypeOverrides
protected List<com.fasterxml.classmate.ResolvedType> resolveTargetTypeOverrides(MemberScope<?,?> member)
Derive target type override from@Schema(implementation = ...).- Parameters:
member- field/method to determine target type override for- Returns:
- single target type override or null
-
shouldBeIgnored
protected boolean shouldBeIgnored(MemberScope<?,?> member)
Determine whether the given field/method should be skipped, based on@Schema(hidden = true).- Parameters:
member- field/method to check- Returns:
- whether to skip the field/method
-
resolvePropertyNameOverride
protected String resolvePropertyNameOverride(MemberScope<?,?> member)
Determine an alternative name for the given field/method, based on@Schema(name = ...).- Parameters:
member- field/method to look-up alternative property name for- Returns:
- alternative property name
-
resolveDescription
protected String resolveDescription(MemberScope<?,?> member)
Look-up description from@Schema(description = ...)for given field/method.- Parameters:
member- field/method to look-up description for- Returns:
- schema description
-
resolveTitle
protected String resolveTitle(MemberScope<?,?> member)
Look-up title from@Schema(title = ...)for given field/method.- Parameters:
member- field/method to look-up title for- Returns:
- schema title
-
checkRequired
protected boolean checkRequired(MemberScope<?,?> member)
Determine whether the given field/method is deemed required in its containing type based on@Schema(required = true).- Parameters:
member- field/method to check- Returns:
- whether the field/method is required
-
checkNullable
protected Boolean checkNullable(MemberScope<?,?> member)
Determine whether the given field/method may be null based on@Schema(nullable = true).- Parameters:
member- field/method to check- Returns:
- whether the field/method is nullable
-
mapAdditionalPropertiesEnumValue
protected Type mapAdditionalPropertiesEnumValue(io.swagger.v3.oas.annotations.media.Schema annotation)
Derive the allowed type of a schema's additional properties from the given annotation.- Parameters:
annotation- annotation to check- Returns:
Object.class(if true or an external "$ref" is specified),Void.class(if forbidden) ornull(if undefined)
-
checkReadOnly
protected boolean checkReadOnly(MemberScope<?,?> member)
Determine whether the given field/method is deemed read-only based on@Schema(accessMode = AccessMode.READ_ONLY).- Parameters:
member- field/method to check- Returns:
- whether the field/method is read-only
-
checkWriteOnly
protected boolean checkWriteOnly(MemberScope<?,?> member)
Determine whether the given field/method is deemed write-only based on@Schema(accessMode = AccessMode.WRITE_ONLY).- Parameters:
member- field/method to check- Returns:
- whether the field/method is write-only
-
resolveEnum
protected List<String> resolveEnum(MemberScope<?,?> member)
Look-up the finite list of possible values from@Schema(allowableValues = ...).- Parameters:
member- field/method to determine allowed values for- Returns:
- applicable "const"/"enum" values or null
-
resolveDefault
protected String resolveDefault(MemberScope<?,?> member)
Look-up the default value for the given field/method from@Schema(defaultValue = ...).- Parameters:
member- field/method to determine default value for- Returns:
- default property value or null
-
resolveMinLength
protected Integer resolveMinLength(MemberScope<?,?> member)
Look-up the value from@Schema(minLength = ...)for the given field/method.- Parameters:
member- field/method to look-up minimum string length for- Returns:
- minimum string length or null
-
resolveMaxLength
protected Integer resolveMaxLength(MemberScope<?,?> member)
Look-up the value from@Schema(maxLength = ...)for the given field/method.- Parameters:
member- field/method to look-up maximum string length for- Returns:
- maximum string length or null
-
resolveFormat
protected String resolveFormat(MemberScope<?,?> member)
Look-up the value from@Schema(format = ...)for the given field/method.- Parameters:
member- field/method to look-up format for- Returns:
- format value or null
-
resolvePattern
protected String resolvePattern(MemberScope<?,?> member)
Look-up the value from@Schema(pattern = ...)for the given field/method.- Parameters:
member- field/method to look-up pattern for- Returns:
- pattern value or null
-
resolveMultipleOf
protected BigDecimal resolveMultipleOf(MemberScope<?,?> member)
Look-up the value from@Schema(multipleOf = ...)for the given field/method.- Parameters:
member- field/method to look-up multipleOf for- Returns:
- multipleOf value or null
-
resolveExclusiveMaximum
protected BigDecimal resolveExclusiveMaximum(MemberScope<?,?> member)
Look-up the exclusive maximum value from@Schema(maximum = ..., exclusiveMaxium = true)for the given field/method.- Parameters:
member- field/method to look-up exclusiveMaximum for- Returns:
- exclusiveMaximum value or null
-
resolveInclusiveMaximum
protected BigDecimal resolveInclusiveMaximum(MemberScope<?,?> member)
Look-up the inclusive maximum value from@Schema(maximum = ..., exclusiveMaxium = false)for the given field/method.- Parameters:
member- field/method to look-up maximum for- Returns:
- maximum value or null
-
resolveExclusiveMinimum
protected BigDecimal resolveExclusiveMinimum(MemberScope<?,?> member)
Look-up the exclusive minimum value from@Schema(minimum = ..., exclusiveMinium = true)for the given field/method.- Parameters:
member- field/method to look-up exclusiveMinimum for- Returns:
- exclusiveMinimum value or null
-
resolveInclusiveMinimum
protected BigDecimal resolveInclusiveMinimum(MemberScope<?,?> member)
Look-up the inclusive minimum value from@Schema(minimum = ..., exclusiveMinium = false)for the given field/method.- Parameters:
member- field/method to look-up minimum for- Returns:
- minimum value or null
-
resolveArrayMinItems
protected Integer resolveArrayMinItems(MemberScope<?,?> member)
Determine the given field/method'sArraySchemaannotation is present and contains a specificminItems.- Parameters:
member- potentially annotated field/method- Returns:
- the
@ArraySchema(minItems)value, otherwisenull
-
resolveArrayMaxItems
protected Integer resolveArrayMaxItems(MemberScope<?,?> member)
Determine the given field/method'sArraySchemaannotation is present and contains a specificmaxItems.- Parameters:
member- potentially annotated field/method- Returns:
- the
@ArraySchema(maxItems)value, otherwisenull
-
resolveArrayUniqueItems
protected Boolean resolveArrayUniqueItems(MemberScope<?,?> member)
Determine the given field/method'sArraySchemaannotation is present and is marked asuniqueItems = true.- Parameters:
member- potentially annotated field/method- Returns:
- whether
@ArraySchema(uniqueItems = true)is present
-
provideCustomSchemaDefinition
protected CustomPropertyDefinition provideCustomSchemaDefinition(MemberScope<?,?> scope, SchemaGenerationContext context)
Implementation of theCustomPropertyDefinitionProviderto consider external references given in@Schema(ref = ...).- Parameters:
scope- field/method to determine custom definition forcontext- generation context- Returns:
- custom definition containing the looked-up external reference or null
-
overrideInstanceAttributes
protected void overrideInstanceAttributes(com.fasterxml.jackson.databind.node.ObjectNode memberAttributes, MemberScope<?,?> member, SchemaGenerationContext context)Consider various remaining aspects.@Schema(not = ...)@Schema(allOf = ...)@Schema(minProperties = ...)@Schema(maxProperties = ...)@Schema(requiredProperties = ...)
- Parameters:
memberAttributes- already collected schema for the field/methodmember- targeted field/methodcontext- generation context
-
-