- AbstractGenerator
Abstract generator which must be implemented by each language
- AbstractRenderer
Abstract renderer with common helper methods
- CommonInputModel
This class is the wrapper for simplified models and the rest of the context needed for further generate typed models.
- CommonModel ⇐
CommonSchema<CommonModel> Common internal representation for a model.
- CommonSchema
CommonSchema which contains the common properties between Schema and CommonModel
- OutputModel
Common representation for the output model.
- RenderOutput
Common representation for the rendered output.
- Schema ⇐
CommonSchema<Schema> JSON Schema Draft 7 model
- 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
- 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
- interpretAdditionalItems(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 additionalProperties keyword.
- interpretAdditionalProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 additionalProperties keyword.
- interpretAllOf(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 allOf keyword.
It either merges allOf schemas into existing model or if allowed, create inheritance.
- interpretConst(schema, model)
Interpreter function for JSON Schema draft 7 const keyword.
- interpretDependencies(schema, model)
Interpreter function for JSON Schema draft 7 dependencies keyword.
- interpretEnum(schema, model)
Interpreter function for JSON Schema draft 7 enum keyword
- interpretItems(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 items keyword.
- interpretArrayItems(rootSchema, itemSchemas, model, interpreter, interpreterOptions)
Internal function to process all item schemas
- interpretNot(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 not keyword.
- interpretPatternProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for JSON Schema draft 7 patternProperties keyword.
- interpretProperties(schema, model, interpreter, interpreterOptions)
Interpreter function for interpreting JSON Schema draft 7 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
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. |
This class is the wrapper for simplified models and the rest of the context needed for further generate typed models.
CommonModel ⇐ CommonSchema<CommonModel>
Common internal representation for a model.
Kind: global class
Extends: CommonSchema<CommonModel>
Properties
| Name | Type | Description |
|---|---|---|
| $id | string |
define the id/name of the model. |
| type | string | Array.<string> |
this is the different types for the model. All types from JSON Schema are used with no custom ones added. |
| enum | Array.<any> |
defines the different enums for the model, constant values are included here |
| items | CommonModel | Array.<CommonModel> |
defines the type for array models as CommonModel. |
| properties | Record.<string, CommonModel> |
defines the properties and its expected types as CommonModel. |
| additionalProperties | CommonModel |
are used to define if any extra properties are allowed, also defined as a CommonModel. |
| patternProperties | Record.<string, CommonModel> |
are used for any extra properties that matches a specific pattern to be of specific type. |
| $ref | string |
is a reference to another CommonModel by using$id as a simple string. |
| required | Array.<string> |
list of required properties. |
| extend | Array.<string> |
list of other CommonModels this model extends, is an array of $id strings. |
| originalSchema | Schema | boolean |
the actual input for which this model represent. |
- CommonModel ⇐
CommonSchema<CommonModel>- instance
- .getFromSchema(key) ⇒
any - .setType(type)
- .removeType(types)
- .addTypes(types)
- .isRequired(propertyName) ⇒
boolean - .addItem(itemModel, schema, addAsArray)
- .addItemTuple(tupleModel, schema, index)
- .addEnum(enumValue)
- .removeEnum(enumValue)
- .addProperty(propertyName, propertyModel, schema)
- .addAdditionalProperty(additionalPropertiesModel, schema)
- .addAdditionalItems(additionalItemsModel, schema)
- .addPatternProperty(pattern, patternModel, schema)
- .addExtendedModel(extendedModel)
- .getNearestDependencies()
- .getFromSchema(key) ⇒
- static
- .toCommonModel(object) ⇒
- .mergeProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- .mergeAdditionalProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- .mergeAdditionalItems(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- .mergePatternProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- .mergeItems(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- .mergeTypes(mergeTo, mergeFrom)
- .mergeCommonModels(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)
- instance
Retrieves data from originalSchema 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 |
|---|
| itemModel |
| schema |
| addAsArray |
Adds a tuple to the model.
If a item already exist it will be merged.
Kind: instance method of CommonModel
| Param |
|---|
| tupleModel |
| schema |
| 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 | |
| schema | schema to the corresponding property model |
Adds additionalProperty to the model. If another model already exist the two are merged.
Kind: instance method of CommonModel
| Param |
|---|
| additionalPropertiesModel |
| schema |
Adds additionalItems to the model. If another model already exist the two are merged.
Kind: instance method of CommonModel
| Param |
|---|
| additionalItemsModel |
| schema |
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 | |
| schema | schema to the corresponding property 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 |
This function returns an array of $ids from all the CommonModel's it immediate depends on.
Kind: instance method of CommonModel
Transform object into a type 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 |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| alreadyIteratedModels |
Merge two common model additionalProperties together
Kind: static method of CommonModel
| Param |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| alreadyIteratedModels |
Merge two common model additionalItems together
Kind: static method of CommonModel
| Param |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| alreadyIteratedModels |
Merge two common model pattern properties together
Kind: static method of CommonModel
| Param |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| alreadyIteratedModels |
Merge items together, prefer tuples over simple array since it is more strict.
Kind: static method of CommonModel
| Param |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| 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 |
|---|
| mergeTo |
| mergeFrom |
| originalSchema |
| alreadyIteratedModels |
CommonSchema which contains the common properties between Schema and CommonModel
Function to transform nested schemas into type of generic extended class
Since both CommonModel and Schema uses these properties we need a common function to convert nested schemas into their corresponding class.
Kind: static method of CommonSchema
| Param | Description |
|---|---|
| schema | to be transformed |
| transformationSchemaCallback | callback to transform nested schemas |
Common representation for the output model.
Common representation for the rendered output.
Schema ⇐ CommonSchema<Schema>
JSON Schema Draft 7 model
Kind: global class
Extends: CommonSchema<Schema>
Transform object into a type of Schema.
Kind: static method of Schema
Returns: CommonModel instance of the object
| Param | Description |
|---|---|
| object | to transform |
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 our 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 |
| type | of processor to use |
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 |
Reflect name from given schema and save it to x-modelgen-inferred-name extension.
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 |
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 |
Interpreter function for JSON Schema draft 7 additionalProperties keyword.
Kind: global function
| Param | Description |
|---|---|
| schema | |
| model | |
| interpreter | |
| interpreterOptions | to control the interpret process |
Interpreter function for JSON Schema draft 7 additionalProperties keyword.
Kind: global function
| Param | Description |
|---|---|
| schema | |
| model | |
| interpreter | |
| interpreterOptions | to control the interpret process |
Interpreter function for JSON Schema draft 7 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 JSON Schema draft 7 const keyword.
Kind: global function
| Param |
|---|
| schema |
| model |
Interpreter function for JSON Schema draft 7 dependencies keyword.
Kind: global function
| Param |
|---|
| schema |
| model |
Interpreter function for JSON Schema draft 7 enum keyword
Kind: global function
| Param |
|---|
| schema |
| model |
Interpreter function for JSON Schema draft 7 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 JSON Schema draft 7 not keyword.
Kind: global function
| Param | Description |
|---|---|
| schema | |
| model | |
| interpreter | |
| interpreterOptions | to control the interpret process |
Interpreter function for JSON Schema draft 7 patternProperties keyword.
Kind: global function
| Param | Description |
|---|---|
| schema | |
| model | |
| interpreter | |
| interpreterOptions | to control the interpret process |
Interpreter function for interpreting JSON Schema draft 7 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 |