Package io.fabric8.crd.generator
Class AbstractJsonSchema<T,B>
- java.lang.Object
-
- io.fabric8.crd.generator.AbstractJsonSchema<T,B>
-
- Type Parameters:
T- the concrete type of the generated JSON SchemaB- the concrete type of the JSON Schema builder
- Direct Known Subclasses:
JsonSchema,JsonSchema
public abstract class AbstractJsonSchema<T,B> extends Object
Encapsulates the common logic supporting OpenAPI schema generation for CRD generation.
-
-
Field Summary
Fields Modifier and Type Field Description protected static io.sundr.codegen.model.TypeDefBOOLEANprotected static io.sundr.codegen.model.TypeRefBOOLEAN_REFprotected static Map<io.sundr.codegen.model.TypeRef,String>COMMON_MAPPINGSprotected static io.sundr.codegen.model.TypeDefDATEprotected static io.sundr.codegen.model.TypeRefDATE_REFprotected static io.sundr.codegen.model.TypeDefDOUBLEprotected static io.sundr.codegen.model.TypeRefDOUBLE_REFprotected static io.sundr.codegen.model.TypeDefDURATIONprotected static io.sundr.codegen.model.TypeRefDURATION_REFprotected static io.sundr.codegen.model.TypeDefINTprotected static io.sundr.codegen.model.TypeDefINT_OR_STRINGprotected static io.sundr.codegen.model.TypeRefINT_OR_STRING_REFprotected static io.sundr.codegen.model.TypeRefINT_REFprotected static io.sundr.codegen.model.TypeDefLONGprotected static io.sundr.codegen.model.TypeRefLONG_REFprotected static io.sundr.codegen.model.TypeRefP_BOOLEAN_REFprotected static io.sundr.codegen.model.TypeRefP_DOUBLE_REFprotected static io.sundr.codegen.model.TypeRefP_INT_REFprotected static io.sundr.codegen.model.TypeRefP_LONG_REFprotected static io.sundr.codegen.model.TypeDefQUANTITYprotected static io.sundr.codegen.model.TypeRefQUANTITY_REFprotected static io.sundr.codegen.model.TypeDefSTRINGprotected static io.sundr.codegen.model.TypeRefSTRING_REF
-
Constructor Summary
Constructors Constructor Description AbstractJsonSchema()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddProperty(io.sundr.codegen.model.Property property, B builder, T schema)Adds the specified property to the specified builder, callinginternalFrom(TypeRef)to create the property schema.abstract Tbuild(B builder, List<String> required)Finishes up the process by actually building the final JSON schema based on the provided builder and a potentially empty list of names of fields which should be marked as requiredprotected abstract TcollectionProperty(T schema)Builds the schema for collection propertiesprotected abstract TenumProperty(com.fasterxml.jackson.databind.JsonNode... enumValues)protected TinternalFrom(io.sundr.codegen.model.TypeDef definition, String... ignore)Creates the JSON schema for the particularTypeDef.TinternalFrom(io.sundr.codegen.model.TypeRef typeRef)Builds the specific JSON schema representing the structural schema for the specified propertyprotected abstract TmappedProperty(io.sundr.codegen.model.TypeRef ref)Builds the schema for specifically handled property types (e.g.abstract BnewBuilder()Creates a new specific builder object.protected abstract TsingleProperty(String typeName)Builds the schema for standard, simple (e.g.
-
-
-
Field Detail
-
QUANTITY
protected static final io.sundr.codegen.model.TypeDef QUANTITY
-
DURATION
protected static final io.sundr.codegen.model.TypeDef DURATION
-
INT_OR_STRING
protected static final io.sundr.codegen.model.TypeDef INT_OR_STRING
-
BOOLEAN
protected static final io.sundr.codegen.model.TypeDef BOOLEAN
-
STRING
protected static final io.sundr.codegen.model.TypeDef STRING
-
INT
protected static final io.sundr.codegen.model.TypeDef INT
-
LONG
protected static final io.sundr.codegen.model.TypeDef LONG
-
DOUBLE
protected static final io.sundr.codegen.model.TypeDef DOUBLE
-
DATE
protected static final io.sundr.codegen.model.TypeDef DATE
-
QUANTITY_REF
protected static final io.sundr.codegen.model.TypeRef QUANTITY_REF
-
DURATION_REF
protected static final io.sundr.codegen.model.TypeRef DURATION_REF
-
INT_OR_STRING_REF
protected static final io.sundr.codegen.model.TypeRef INT_OR_STRING_REF
-
BOOLEAN_REF
protected static final io.sundr.codegen.model.TypeRef BOOLEAN_REF
-
STRING_REF
protected static final io.sundr.codegen.model.TypeRef STRING_REF
-
INT_REF
protected static final io.sundr.codegen.model.TypeRef INT_REF
-
LONG_REF
protected static final io.sundr.codegen.model.TypeRef LONG_REF
-
DOUBLE_REF
protected static final io.sundr.codegen.model.TypeRef DOUBLE_REF
-
DATE_REF
protected static final io.sundr.codegen.model.TypeRef DATE_REF
-
P_INT_REF
protected static final io.sundr.codegen.model.TypeRef P_INT_REF
-
P_LONG_REF
protected static final io.sundr.codegen.model.TypeRef P_LONG_REF
-
P_DOUBLE_REF
protected static final io.sundr.codegen.model.TypeRef P_DOUBLE_REF
-
P_BOOLEAN_REF
protected static final io.sundr.codegen.model.TypeRef P_BOOLEAN_REF
-
-
Method Detail
-
internalFrom
protected T internalFrom(io.sundr.codegen.model.TypeDef definition, String... ignore)
Creates the JSON schema for the particularTypeDef. This is template method where sub-classes are supposed to provide specific implementations of abstract methods.- Parameters:
definition- The definition.ignore- a potentially empty list of property names to ignore while generating the schema- Returns:
- The schema.
-
newBuilder
public abstract B newBuilder()
Creates a new specific builder object.- Returns:
- a new builder object specific to the CRD generation version
-
addProperty
public abstract void addProperty(io.sundr.codegen.model.Property property, B builder, T schema)Adds the specified property to the specified builder, callinginternalFrom(TypeRef)to create the property schema.- Parameters:
property- the property to add to the currently being built schemabuilder- the builder representing the schema being builtschema- the built schema for the property being added
-
build
public abstract T build(B builder, List<String> required)
Finishes up the process by actually building the final JSON schema based on the provided builder and a potentially empty list of names of fields which should be marked as required- Parameters:
builder- the builder used to build the final schemarequired- the list of names of required fields- Returns:
- the built JSON schema
-
internalFrom
public T internalFrom(io.sundr.codegen.model.TypeRef typeRef)
Builds the specific JSON schema representing the structural schema for the specified property- Parameters:
typeRef- the type of the property which schema we want to build- Returns:
- the structural schema associated with the specified property
-
mappedProperty
protected abstract T mappedProperty(io.sundr.codegen.model.TypeRef ref)
Builds the schema for specifically handled property types (e.g. intOrString properties)- Parameters:
ref- the type of the specifically handled property- Returns:
- the property schema
-
collectionProperty
protected abstract T collectionProperty(T schema)
Builds the schema for collection properties- Parameters:
schema- the schema for the extracted element type for this collection-like property- Returns:
- the schema for the collection-like property
-
singleProperty
protected abstract T singleProperty(String typeName)
Builds the schema for standard, simple (e.g. string) property types- Parameters:
typeName- the mapped name of the property type- Returns:
- the schema for the property
-
enumProperty
protected abstract T enumProperty(com.fasterxml.jackson.databind.JsonNode... enumValues)
-
-