- AbstractGenerator
Abstract generator which must be implemented by each language
- AbstractRenderer
Abstract renderer with common helper methods
- AsyncapiV2Schema
AsyncAPI schema model
Based on Draft 7 with additions
https://www.asyncapi.com/docs/specifications/v2.0.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.1.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.2.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.3.0#schemaObject
- CommonInputModel
This class is the wrapper for simplified models and the rest of the context needed for further generate typed models.
- CommonModel
Common internal representation for a model.
- Draft4Schema
JSON Draft 4 schema model
- Draft6Schema
JSON Draft 6 schema model
- Draft7Schema
JSON Draft7Schema Draft 7 model
- OpenapiV3Schema
OpenAPI 3.0 -> 3.0.4 schema model
Based on Draft 6, but with restricted keywords and definitions Modifications
- type, cannot be an array nor contain 'null'
Restrictions (keywords not allowed)
- patternProperties
- not
- OutputModel
Common representation for the output model.
- RenderOutput
Common representation for the rendered output.
- SwaggerV2Schema
OpenAPI 2.0 (Swagger 2.0) schema model
Based on Draft 4, but with restricted keywords and definitions
Restrictions (keywords not allowed)
- oneOf
- anyOf
- patternProperties
- not
- AsyncAPIInputProcessor
Class for processing AsyncAPI inputs
- InputProcessor
Main input processor which figures out the type of input it receives and delegates the processing into separate individual processors.
- JsonSchemaInputProcessor
Class for processing JSON Schema
- OpenAPIInputProcessor
Class for processing OpenAPI V3.0 inputs
- SwaggerInputProcessor
Class for processing Swagger inputs
- LoggerClass
Logger class for the model generation library
This class acts as a forefront for any external loggers which is why it also implements the interface itself.
- DefaultPropertyNames
Default property names for different aspects of the common model
- CommonNamingConventionImplementation
A CommonNamingConvention implementation shared between generators for different languages.
- getUniquePropertyName(rootModel, propertyName)
Recursively find the proper property name.
This function ensures that the property name is unique for the model
- hasPreset(presets, preset)
Returns true if and only if a given preset is already included in a list of presets Check is done using referential equality
- interpretAdditionalItems(schema, model, interpreter, interpreterOptions)
Interpreter function for additionalItems keyword.
- interpretAdditionalProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for additionalProperties keyword.
- interpretAllOf(schema, model, interpreter, interpreterOptions)
Interpreter function for allOf keyword.
It either merges allOf schemas into existing model or if allowed, create inheritance.
- interpretConst(schema, model)
Interpreter function for const keyword for draft version > 4
- interpretDependencies(schema, model)
Interpreter function for dependencies keyword.
- interpretEnum(schema, model)
Interpreter function for enum keyword
- interpretItems(schema, model, interpreter, interpreterOptions)
Interpreter function for items keyword.
- interpretArrayItems(rootSchema, itemSchemas, model, interpreter, interpreterOptions)
Internal function to process all item schemas
- interpretNot(schema, model, interpreter, interpreterOptions)
Interpreter function for not keyword.
- interpretPatternProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for patternProperties keyword.
- interpretProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for interpreting properties keyword.
- postInterpretModel(model)
Post process the interpreted model. By applying the following:
- Ensure models are split as required
- trySplitModels(model, iteratedModels)
This function splits up a model if needed and add the new model to the list of models.
- ensureModelsAreSplit(model, iteratedModels)
Split up all models which should and use ref instead.
- isEnum(model)
Check if CommonModel is an enum
- isModelObject(model)
Check if CommonModel is a separate model or a simple model.
- inferTypeFromValue(value)
Infers the JSON Schema type from value
- interpretName(schema)
Find the name for simplified version of schema
Abstract generator which must be implemented by each language
Kind: global class
Generates the full output of a model, instead of a scattered model.
OutputModels result is no longer the model itself, but including package, package dependencies and model dependencies.
Kind: instance method of AbstractGenerator
Param | Description |
---|---|
input | |
options | to use for rendering full output |
Generates a scattered model where dependencies and rendered results are separated.
Kind: instance method of AbstractGenerator
Param |
---|
input |
Process any of the input formats to the appropriate CommonInputModel type.
Kind: instance method of AbstractGenerator
Param |
---|
input |
Abstract renderer with common helper methods
Adds a dependency while ensuring that only one dependency is preset at a time.
Kind: instance method of AbstractRenderer
Param | Description |
---|---|
dependency | complete dependency string so it can be rendered as is. |
AsyncAPI schema model
Based on Draft 7 with additions
https://www.asyncapi.com/docs/specifications/v2.0.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.1.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.2.0#schemaObject https://www.asyncapi.com/docs/specifications/v2.3.0#schemaObject
Takes a deep copy of the input object and converts it to an instance of AsyncapiV2Schema.
Kind: static method of AsyncapiV2Schema
Param |
---|
object |
This class is the wrapper for simplified models and the rest of the context needed for further generate typed models.
Common internal representation for a model.
Kind: global class
- CommonModel
- instance
- .getFromOriginalInput(key) ⇒
any
- .setType(type)
- .removeType(types)
- .addTypes(types)
- .isRequired(propertyName) ⇒
boolean
- .addItem(itemModel, originalInput)
- .addItemTuple(tupleModel, originalInput, index)
- .addEnum(enumValue)
- .removeEnum(enumValue)
- .addProperty(propertyName, propertyModel, originalInput)
- .addAdditionalProperty(additionalPropertiesModel, originalInput)
- .addAdditionalItems(additionalItemsModel, originalInput)
- .addPatternProperty(pattern, patternModel, originalInput)
- .addExtendedModel(extendedModel)
- .getNearestDependencies()
- .getFromOriginalInput(key) ⇒
- static
- .toCommonModel(object) ⇒
- .mergeProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- .mergeAdditionalProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- .mergeAdditionalItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- .mergePatternProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- .mergeItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- .mergeTypes(mergeTo, mergeFrom)
- .mergeCommonModels(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)
- instance
Retrieves data from originalInput by given key
Kind: instance method of CommonModel
Param | Description |
---|---|
key | given key |
Set the types of the model
Kind: instance method of CommonModel
Param |
---|
type |
Removes type(s) from model type
Kind: instance method of CommonModel
Param |
---|
types |
Adds types to the existing model types.
Makes sure to only keep a single type incase of duplicates.
Kind: instance method of CommonModel
Param | Description |
---|---|
types | which types we should try and add to the existing output |
Checks if given property name is required in object
Kind: instance method of CommonModel
Param | Description |
---|---|
propertyName | given property name |
Adds an item to the model.
If items already exist the two are merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
itemModel | |
originalInput | corresponding input that got interpreted to this model |
Adds a tuple to the model.
If a item already exist it will be merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
tupleModel | |
originalInput | corresponding input that got interpreted to this model |
index |
Add enum value to the model.
Ensures no duplicates are added.
Kind: instance method of CommonModel
Param |
---|
enumValue |
Remove enum from model.
Kind: instance method of CommonModel
Param |
---|
enumValue |
Adds a property to the model. If the property already exist the two are merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
propertyName | |
propertyModel | |
originalInput | corresponding input that got interpreted to this model |
Adds additionalProperty to the model. If another model already exist the two are merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
additionalPropertiesModel | |
originalInput | corresponding input that got interpreted to this model corresponding input that got interpreted to this model |
Adds additionalItems to the model. If another model already exist the two are merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
additionalItemsModel | |
originalInput | corresponding input that got interpreted to this model |
Adds a patternProperty to the model. If the pattern already exist the two models are merged.
Kind: instance method of CommonModel
Param | Description |
---|---|
pattern | |
patternModel | |
originalInput | corresponding input that got interpreted to this model |
Adds another model this model should extend.
It is only allowed to extend if the other model have $id and is not already being extended.
Kind: instance method of CommonModel
Param |
---|
extendedModel |
Returns an array of unique $id
s from all the CommonModel's this model depends on.
Kind: instance method of CommonModel
Takes a deep copy of the input object and converts it to an instance of CommonModel.
Kind: static method of CommonModel
Returns: CommonModel instance of the object
Param | Description |
---|---|
object | to transform |
Merge two common model properties together
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
Merge two common model additionalProperties together
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
Merge two common model additionalItems together
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
Merge two common model pattern properties together
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
Merge items together, prefer tuples over simple array since it is more strict.
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
Merge types together
Kind: static method of CommonModel
Param |
---|
mergeTo |
mergeFrom |
Only merge if left side is undefined and right side is sat OR both sides are defined
Kind: static method of CommonModel
Param | Description |
---|---|
mergeTo | |
mergeFrom | |
originalInput | corresponding input that got interpreted to this model |
alreadyIteratedModels |
JSON Draft 4 schema model
Takes a deep copy of the input object and converts it to an instance of Draft4Schema.
Kind: static method of Draft4Schema
Param |
---|
object |
JSON Draft 6 schema model
Takes a deep copy of the input object and converts it to an instance of Draft6Schema.
Kind: static method of Draft6Schema
Param |
---|
object |
JSON Draft7Schema Draft 7 model
Takes a deep copy of the input object and converts it to an instance of Draft7Schema.
Kind: static method of Draft7Schema
Param |
---|
object |
OpenAPI 3.0 -> 3.0.4 schema model
Based on Draft 6, but with restricted keywords and definitions Modifications
- type, cannot be an array nor contain 'null'
Restrictions (keywords not allowed)
- patternProperties
- not
https://swagger.io/specification/#schema-object
Takes a deep copy of the input object and converts it to an instance of OpenapiV3Schema.
Kind: static method of OpenapiV3Schema
Param |
---|
object |
Common representation for the output model.
Common representation for the rendered output.
OpenAPI 2.0 (Swagger 2.0) schema model
Based on Draft 4, but with restricted keywords and definitions
Restrictions (keywords not allowed)
- oneOf
- anyOf
- patternProperties
- not
https://swagger.io/specification/v2/#schemaObject
Takes a deep copy of the input object and converts it to an instance of SwaggerV2Schema.
Kind: static method of SwaggerV2Schema
Param |
---|
object |
Class for processing AsyncAPI inputs
Kind: global class
Process the input as an AsyncAPI document
Kind: instance method of AsyncAPIInputProcessor
Param |
---|
input |
Figures out if an object is of type AsyncAPI document
Kind: instance method of AsyncAPIInputProcessor
Param |
---|
input |
Try to find the AsyncAPI version from the input. If it cannot undefined are returned, if it can, the version is returned.
Kind: instance method of AsyncAPIInputProcessor
Param |
---|
input |
Reflect the name of the schema and save it to x-modelgen-inferred-name
extension.
This keeps the the id of the model deterministic if used in conjunction with other AsyncAPI tools such as the generator.
Kind: static method of AsyncAPIInputProcessor
Param | Description |
---|---|
schema | to reflect name for |
Figure out if input is from the AsyncAPI js parser.
Kind: static method of AsyncAPIInputProcessor
Param |
---|
input |
Main input processor which figures out the type of input it receives and delegates the processing into separate individual processors.
Kind: global class
Set a processor.
Kind: instance method of InputProcessor
Param | Description |
---|---|
type | of processor |
processor |
Kind: instance method of InputProcessor
Returns: all processors
The processor code which delegates the processing to the correct implementation.
Kind: instance method of InputProcessor
Param | Description |
---|---|
input | to process |
options | passed to the processors |
Class for processing JSON Schema
Kind: global class
Function for processing a JSON Schema input.
Kind: instance method of JsonSchemaInputProcessor
Param |
---|
input |
Unless the schema states one that is not supported we assume its of type JSON Schema
Kind: instance method of JsonSchemaInputProcessor
Param |
---|
input |
Process a draft-7 schema
Kind: instance method of JsonSchemaInputProcessor
Param | Description |
---|---|
input | to process as draft 7 |
Process a draft-4 schema
Kind: instance method of JsonSchemaInputProcessor
Param | Description |
---|---|
input | to process as draft 4 |
Process a draft-6 schema
Kind: instance method of JsonSchemaInputProcessor
Param | Description |
---|---|
input | to process as draft-6 |
Each schema must have a name, so when later interpreted, the model have the most accurate model name.
Reflect name from given schema and save it to x-modelgen-inferred-name
extension.
This reflects all the common keywords that are shared between draft-4, draft-7 and Swagger 2.0 Schema
Kind: static method of JsonSchemaInputProcessor
Param | Description |
---|---|
schema | to process |
namesStack | is a aggegator of previous used names |
name | to infer |
isRoot | indicates if performed schema is a root schema |
Ensure schema name using previous name and new part
Kind: static method of JsonSchemaInputProcessor
Param | Description |
---|---|
previousName | to concatenate with |
...newParts |
Simplifies a JSON Schema into a common models
Kind: static method of JsonSchemaInputProcessor
Param | Description |
---|---|
schema | to simplify to common model |
Class for processing OpenAPI V3.0 inputs
Kind: global class
Process the input as a OpenAPI V3.0 document
Kind: instance method of OpenAPIInputProcessor
Param |
---|
input |
Figures out if an object is of type OpenAPI V3.0.x document and supported
Kind: instance method of OpenAPIInputProcessor
Param |
---|
input |
Try to find the AsyncAPI version from the input. If it cannot undefined are returned, if it can, the version is returned.
Kind: instance method of OpenAPIInputProcessor
Param |
---|
input |
Converts a schema to the internal schema format.
Kind: static method of OpenAPIInputProcessor
Param | Description |
---|---|
schema | to convert |
name | of the schema |
Class for processing Swagger inputs
Kind: global class
Process the input as a Swagger document
Kind: instance method of SwaggerInputProcessor
Param |
---|
input |
Figures out if an object is of type Swagger document and supported
Kind: instance method of SwaggerInputProcessor
Param |
---|
input |
Try to find the swagger version from the input. If it cannot, undefined are returned, if it can, the version is returned.
Kind: instance method of SwaggerInputProcessor
Param |
---|
input |
Converts a Swagger 2.0 Schema to the internal schema format.
Kind: static method of SwaggerInputProcessor
Param | Description |
---|---|
schema | to convert |
name | of the schema |
Logger class for the model generation library
This class acts as a forefront for any external loggers which is why it also implements the interface itself.
Sets the logger to use for the model generation library
Kind: instance method of LoggerClass
Param | Description |
---|---|
logger | to add |
Default property names for different aspects of the common model
A CommonNamingConvention implementation shared between generators for different languages.
Recursively find the proper property name.
This function ensures that the property name is unique for the model
Kind: global function
Param |
---|
rootModel |
propertyName |
Returns true if and only if a given preset is already included in a list of presets Check is done using referential equality
Kind: global function
Param | Description |
---|---|
presets | the list to check |
preset | the preset to check for |
Interpreter function for additionalItems keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for additionalProperties keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for allOf keyword.
It either merges allOf schemas into existing model or if allowed, create inheritance.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for const keyword for draft version > 4
Kind: global function
Param |
---|
schema |
model |
Interpreter function for dependencies keyword.
Kind: global function
Param |
---|
schema |
model |
Interpreter function for enum keyword
Kind: global function
Param |
---|
schema |
model |
Interpreter function for items keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Internal function to process all item schemas
Kind: global function
Param | Description |
---|---|
rootSchema | |
itemSchemas | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for not keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for patternProperties keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Interpreter function for interpreting properties keyword.
Kind: global function
Param | Description |
---|---|
schema | |
model | |
interpreter | |
interpreterOptions | to control the interpret process |
Post process the interpreted model. By applying the following:
- Ensure models are split as required
Kind: global function
Param |
---|
model |
This function splits up a model if needed and add the new model to the list of models.
Kind: global function
Param | Description |
---|---|
model | check if it should be split up |
iteratedModels | which have already been split up |
Split up all models which should and use ref instead.
Kind: global function
Param | Description |
---|---|
model | to ensure are split |
iteratedModels | which are already split |
Check if CommonModel is an enum
Kind: global function
Param |
---|
model |
Check if CommonModel is a separate model or a simple model.
Kind: global function
Param |
---|
model |
Infers the JSON Schema type from value
Kind: global function
Param | Description |
---|---|
value | to infer type of |
Find the name for simplified version of schema
Kind: global function
Param | Description |
---|---|
schema | to find the name |