Skip to content

Latest commit

 

History

History
1020 lines (732 loc) · 30.8 KB

File metadata and controls

1020 lines (732 loc) · 30.8 KB

Classes

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.

CommonModelCommonSchema<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.

SchemaCommonSchema<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.

Members

DefaultPropertyNames

Default property names for different aspects of the common model

CommonNamingConventionImplementation

A CommonNamingConvention implementation shared between generators for different languages.

Functions

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

AbstractGenerator

Abstract generator which must be implemented by each language

Kind: global class

AbstractRenderer

Abstract renderer with common helper methods

Kind: global class

abstractRenderer.addDependency(dependency)

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.

CommonInputModel

This class is the wrapper for simplified models and the rest of the context needed for further generate typed models.

Kind: global class

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.getFromSchema(key) ⇒ any

Retrieves data from originalSchema by given key

Kind: instance method of CommonModel

Param Description
key given key

commonModel.setType(type)

Set the types of the model

Kind: instance method of CommonModel

Param
type

commonModel.removeType(types)

Removes type(s) from model type

Kind: instance method of CommonModel

Param
types

commonModel.addTypes(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

commonModel.isRequired(propertyName) ⇒ boolean

Checks if given property name is required in object

Kind: instance method of CommonModel

Param Description
propertyName given property name

commonModel.addItem(itemModel, schema, addAsArray)

Adds an item to the model.

If items already exist the two are merged.

Kind: instance method of CommonModel

Param
itemModel
schema
addAsArray

commonModel.addItemTuple(tupleModel, schema, index)

Adds a tuple to the model.

If a item already exist it will be merged.

Kind: instance method of CommonModel

Param
tupleModel
schema
index

commonModel.addEnum(enumValue)

Add enum value to the model.

Ensures no duplicates are added.

Kind: instance method of CommonModel

Param
enumValue

commonModel.removeEnum(enumValue)

Remove enum from model.

Kind: instance method of CommonModel

Param
enumValue

commonModel.addProperty(propertyName, propertyModel, schema)

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

commonModel.addAdditionalProperty(additionalPropertiesModel, schema)

Adds additionalProperty to the model. If another model already exist the two are merged.

Kind: instance method of CommonModel

Param
additionalPropertiesModel
schema

commonModel.addAdditionalItems(additionalItemsModel, schema)

Adds additionalItems to the model. If another model already exist the two are merged.

Kind: instance method of CommonModel

Param
additionalItemsModel
schema

commonModel.addPatternProperty(pattern, patternModel, 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

commonModel.addExtendedModel(extendedModel)

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

commonModel.getNearestDependencies()

This function returns an array of $ids from all the CommonModel's it immediate depends on.

Kind: instance method of CommonModel

CommonModel.toCommonModel(object) ⇒

Transform object into a type of CommonModel.

Kind: static method of CommonModel
Returns: CommonModel instance of the object

Param Description
object to transform

CommonModel.mergeProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)

Merge two common model properties together

Kind: static method of CommonModel

Param
mergeTo
mergeFrom
originalSchema
alreadyIteratedModels

CommonModel.mergeAdditionalProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)

Merge two common model additionalProperties together

Kind: static method of CommonModel

Param
mergeTo
mergeFrom
originalSchema
alreadyIteratedModels

CommonModel.mergeAdditionalItems(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)

Merge two common model additionalItems together

Kind: static method of CommonModel

Param
mergeTo
mergeFrom
originalSchema
alreadyIteratedModels

CommonModel.mergePatternProperties(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)

Merge two common model pattern properties together

Kind: static method of CommonModel

Param
mergeTo
mergeFrom
originalSchema
alreadyIteratedModels

CommonModel.mergeItems(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

CommonModel.mergeTypes(mergeTo, mergeFrom)

Merge types together

Kind: static method of CommonModel

Param
mergeTo
mergeFrom

CommonModel.mergeCommonModels(mergeTo, mergeFrom, originalSchema, alreadyIteratedModels)

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

CommonSchema which contains the common properties between Schema and CommonModel

Kind: global class

CommonSchema.transformSchema(schema, transformationSchemaCallback)

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

OutputModel

Common representation for the output model.

Kind: global class

RenderOutput

Common representation for the rendered output.

Kind: global class

JSON Schema Draft 7 model

Kind: global class
Extends: CommonSchema<Schema>

Schema.toSchema(object) ⇒

Transform object into a type of Schema.

Kind: static method of Schema
Returns: CommonModel instance of the object

Param Description
object to transform

AsyncAPIInputProcessor

Class for processing AsyncAPI inputs

Kind: global class

asyncAPIInputProcessor.process(input)

Process the input as an AsyncAPI document

Kind: instance method of AsyncAPIInputProcessor

Param
input

asyncAPIInputProcessor.shouldProcess(input)

Figures out if an object is of type AsyncAPI document

Kind: instance method of AsyncAPIInputProcessor

Param
input

asyncAPIInputProcessor.tryGetVersionOfDocument(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

AsyncAPIInputProcessor.convertToInternalSchema(schema)

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

AsyncAPIInputProcessor.isFromParser(input)

Figure out if input is from our parser.

Kind: static method of AsyncAPIInputProcessor

Param
input

InputProcessor

Main input processor which figures out the type of input it receives and delegates the processing into separate individual processors.

Kind: global class

inputProcessor.setProcessor(type, processor)

Set a processor.

Kind: instance method of InputProcessor

Param Description
type of processor
processor

inputProcessor.getProcessors() ⇒

Kind: instance method of InputProcessor
Returns: all processors

inputProcessor.process(input, type)

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

JsonSchemaInputProcessor

Class for processing JSON Schema

Kind: global class

jsonSchemaInputProcessor.process(input)

Function for processing a JSON Schema input.

Kind: instance method of JsonSchemaInputProcessor

Param
input

jsonSchemaInputProcessor.shouldProcess(input)

Unless the schema states one that is not supported we assume its of type JSON Schema

Kind: instance method of JsonSchemaInputProcessor

Param
input

jsonSchemaInputProcessor.processDraft7(input)

Process a draft 7 schema

Kind: instance method of JsonSchemaInputProcessor

Param Description
input to process as draft 7

JsonSchemaInputProcessor.reflectSchemaNames(schema, namesStack, name, isRoot)

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

JsonSchemaInputProcessor.ensureNamePattern(previousName, ...newParts)

Ensure schema name using previous name and new part

Kind: static method of JsonSchemaInputProcessor

Param Description
previousName to concatenate with
...newParts

JsonSchemaInputProcessor.convertSchemaToCommonModel(schema)

Simplifies a JSON Schema into a common models

Kind: static method of JsonSchemaInputProcessor

Param Description
schema to simplify to common model

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.

Kind: global class

loggerClass.setLogger(logger)

Sets the logger to use for the model generation library

Kind: instance method of LoggerClass

Param Description
logger to add

DefaultPropertyNames

Default property names for different aspects of the common model

Kind: global variable

CommonNamingConventionImplementation

A CommonNamingConvention implementation shared between generators for different languages.

Kind: global variable

getUniquePropertyName(rootModel, propertyName)

Recursively find the proper property name.

This function ensures that the property name is unique for the model

Kind: global function

Param
rootModel
propertyName

interpretAdditionalItems(schema, model, interpreter, interpreterOptions)

Interpreter function for JSON Schema draft 7 additionalProperties keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

interpretAdditionalProperties(schema, model, interpreter, interpreterOptions)

Interpreter function for JSON Schema draft 7 additionalProperties keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

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.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

interpretConst(schema, model)

Interpreter function for JSON Schema draft 7 const keyword.

Kind: global function

Param
schema
model

interpretDependencies(schema, model)

Interpreter function for JSON Schema draft 7 dependencies keyword.

Kind: global function

Param
schema
model

interpretEnum(schema, model)

Interpreter function for JSON Schema draft 7 enum keyword

Kind: global function

Param
schema
model

interpretItems(schema, model, interpreter, interpreterOptions)

Interpreter function for JSON Schema draft 7 items keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

interpretArrayItems(rootSchema, itemSchemas, model, interpreter, interpreterOptions)

Internal function to process all item schemas

Kind: global function

Param Description
rootSchema
itemSchemas
model
interpreter
interpreterOptions to control the interpret process

interpretNot(schema, model, interpreter, interpreterOptions)

Interpreter function for JSON Schema draft 7 not keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

interpretPatternProperties(schema, model, interpreter, interpreterOptions)

Interpreter function for JSON Schema draft 7 patternProperties keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

interpretProperties(schema, model, interpreter, interpreterOptions)

Interpreter function for interpreting JSON Schema draft 7 properties keyword.

Kind: global function

Param Description
schema
model
interpreter
interpreterOptions to control the interpret process

postInterpretModel(model)

Post process the interpreted model. By applying the following:

  • Ensure models are split as required

Kind: global function

Param
model

trySplitModels(model, iteratedModels)

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

ensureModelsAreSplit(model, iteratedModels)

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

isEnum(model)

Check if CommonModel is an enum

Kind: global function

Param
model

isModelObject(model)

Check if CommonModel is a separate model or a simple model.

Kind: global function

Param
model

inferTypeFromValue(value)

Infers the JSON Schema type from value

Kind: global function

Param Description
value to infer type of

interpretName(schema)

Find the name for simplified version of schema

Kind: global function

Param Description
schema to find the name