diff --git a/.gitignore b/.gitignore index 646de4c62f..cdbe67507e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,4 @@ lib output # Where the runtime testing for Java places node modules java_runtime_node -*.log - -# API documentation -modelina-website/public/docs/api/generated \ No newline at end of file +*.log \ No newline at end of file diff --git a/API.md b/API.md new file mode 100644 index 0000000000..4dbac13865 --- /dev/null +++ b/API.md @@ -0,0 +1,1538 @@ +## Classes + +
+
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

+
+
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

+
+
InputMetaModel
+

Since each input processor can create multiple meta models this is a wrapper to a MetaModel to make that possible.

+
+
OpenapiV3Schema
+

OpenAPI 3.0 -> 3.0.4 schema model

+

Based on Draft 6, but with restricted keywords and definitions +Modifications

+ +

Restrictions (keywords not allowed)

+ +

https://swagger.io/specification/#schema-object

+
+
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)

+ +

https://swagger.io/specification/v2/#schemaObject

+
+
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

+
+
TemplateInputProcessor
+

Class for processing X input

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

+
+
+ +## Functions + +
+
convertToUnionModel()
+

Converts a CommonModel into multiple models wrapped in a union model.

+

Because a CommonModel might contain multiple models, it's name for each of those models would be the same, instead we slightly change the model name. +Each model has it's type as a name prepended to the union name.

+

If the CommonModel has multiple types

+
+
isDictionary()
+

Determine whether we have a dictionary or an object. because in some cases inputs might be: +{ "type": "object", "additionalProperties": { "$ref": "#" } } which is to be interpreted as a dictionary not an object model.

+
+
getOriginalInputFromAdditionalAndPatterns()
+

Return the original input based on additionalProperties and patternProperties.

+
+
convertAdditionalAndPatterns()
+

Function creating the right meta model based on additionalProperties and patternProperties.

+
+
NO_DUPLICATE_PROPERTIES(constrainedObjectModel, objectModel, propertyName, namingFormatter)
+

Because a lot of the other constrain functions (such as NO_NUMBER_START_CHAR, NO_EMPTY_VALUE, etc) they might manipulate the property names by append, prepend, or manipulate it any other way. +We then need to make sure that they don't clash with any existing properties, this is what this function handles. +If so, prepend reserved_ to the property name and recheck.

+
+
NO_DUPLICATE_ENUM_KEYS(constrainedEnumModel, enumModel, enumKey, namingFormatter, enumKeyToCheck, onNameChange, onNameChangeToCheck)string
+

Because a lot of the other constrain functions (such as NO_NUMBER_START_CHAR, NO_EMPTY_VALUE, etc) they might manipulate the enum keys by append, prepend, or manipulate it any other way. +We then need to make sure that they don't clash with any existing enum keys, this is what this function handles. +If so, prepend reserved_ to the enum key and recheck.

+
+
renderJavaScriptDependency(toImport, fromModule, moduleSystem)
+

Function to make it easier to render JS/TS dependencies based on module system

+
+
makeUnique(array)
+

Function to make an array of ConstrainedMetaModels only contain unique values (ignores different in memory instances)

+
+
lengthInUtf8Bytes()
+

Convert a string into utf-8 encoding and return the byte size.

+
+
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

+
+
trySplitModel(model, options, models)
+

Try split the model

+
+
split(model, options, models)
+

Overwrite the nested models with references where required.

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

+
+
interpretAnyOf(schema, model, interpreter, interpreterOptions)
+

Interpreter function for anyOf keyword.

+

It puts the schema reference into the items field.

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

+
+
interpretOneOf(schema, model, interpreter, interpreterOptions)
+

Interpreter function for oneOf keyword.

+

It puts the schema reference into the items field.

+
+
interpretOneOfWithAllOf(schema, model, interpreter, interpreterOptions)
+

Interpreter function for oneOf keyword combined with the allOf keyword.

+

It merges the allOf schemas into all of the oneOf schemas. Shared properties are merged. The oneOf schemas are then added as union to the model.

+
+
interpretOneOfWithProperties(schema, model, interpreter, interpreterOptions)
+

Interpreter function for oneOf keyword combined with properties.

+

It merges the properties of the schema into the oneOf schemas. Shared properties are merged. The oneOf schemas are then added as union to the model.

+
+
interpretPatternProperties(schema, model, interpreter, interpreterOptions)
+

Interpreter function for patternProperties keyword.

+
+
interpretProperties(schema, model, interpreter, interpreterOptions)
+

Interpreter function for interpreting properties keyword.

+
+
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

+
+
isClass(obj)
+

Return true or false based on whether the input object is a regular object or a class

+

Taken from: https://stackoverflow.com/a/43197340/6803886

+
+
mergePartialAndDefault()
+

Merge a non optional value with custom optional values to form a full value that has all properties sat.

+
+
+ + + +## AbstractGenerator +Abstract generator which must be implemented by each language + +**Kind**: global class + +* [AbstractGenerator](#AbstractGenerator) + * [.getDependencyManagerInstance()](#AbstractGenerator+getDependencyManagerInstance) + * [.generateCompleteModels()](#AbstractGenerator+generateCompleteModels) + * [.generate()](#AbstractGenerator+generate) + * [.processInput(input)](#AbstractGenerator+processInput) + * [.getPresets()](#AbstractGenerator+getPresets) + + + +### abstractGenerator.getDependencyManagerInstance() +This function returns an instance of the dependency manager which is either a factory or an instance. + +**Kind**: instance method of [AbstractGenerator](#AbstractGenerator) + + +### abstractGenerator.generateCompleteModels() +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](#AbstractGenerator) + + +### abstractGenerator.generate() +Generates a scattered model where dependencies and rendered results are separated. + +**Kind**: instance method of [AbstractGenerator](#AbstractGenerator) + + +### abstractGenerator.processInput(input) +Process any of the input formats to the appropriate InputMetaModel type and split out the meta models +based on the requirements of the generators + +**Kind**: instance method of [AbstractGenerator](#AbstractGenerator) + +| Param | +| --- | +| input | + + + +### abstractGenerator.getPresets() +Get all presets (default and custom ones from options) for a given preset type (class, enum, etc). + +**Kind**: instance method of [AbstractGenerator](#AbstractGenerator) + + +## AbstractRenderer +Abstract renderer with common helper methods + +**Kind**: global class + + +## 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 + +**Kind**: global class + + +### AsyncapiV2Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of AsyncapiV2Schema. + +**Kind**: static method of [AsyncapiV2Schema](#AsyncapiV2Schema) + +| Param | +| --- | +| object | + + + +## CommonModel +Common internal representation for a model. + +**Kind**: global class + +* [CommonModel](#CommonModel) + * _instance_ + * [.getFromOriginalInput(key)](#CommonModel+getFromOriginalInput) ⇒ any + * [.setType(type)](#CommonModel+setType) + * [.removeType(types)](#CommonModel+removeType) + * [.addTypes(types)](#CommonModel+addTypes) + * [.isRequired(propertyName)](#CommonModel+isRequired) ⇒ boolean + * [.addItem(itemModel, originalInput)](#CommonModel+addItem) + * [.addItemTuple(tupleModel, originalInput, index)](#CommonModel+addItemTuple) + * [.addItemUnion(unionModel)](#CommonModel+addItemUnion) + * [.addEnum(enumValue)](#CommonModel+addEnum) + * [.removeEnum(enumValue)](#CommonModel+removeEnum) + * [.addProperty(propertyName, propertyModel, originalInput)](#CommonModel+addProperty) + * [.addAdditionalProperty(additionalPropertiesModel, originalInput)](#CommonModel+addAdditionalProperty) + * [.addPatternProperty(pattern, patternModel, originalInput)](#CommonModel+addPatternProperty) + * [.addAdditionalItems(additionalItemsModel, originalInput)](#CommonModel+addAdditionalItems) + * [.addExtendedModel(extendedModel)](#CommonModel+addExtendedModel) + * _static_ + * [.toCommonModel(object)](#CommonModel.toCommonModel) ⇒ + * [.mergeProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergeProperties) + * [.mergeAdditionalProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergeAdditionalProperties) + * [.mergeAdditionalItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergeAdditionalItems) + * [.mergeItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergeItems) + * [.mergePatternProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergePatternProperties) + * [.mergeTypes(mergeTo, mergeFrom)](#CommonModel.mergeTypes) + * [.mergeCommonModels(mergeTo, mergeFrom, originalInput, alreadyIteratedModels)](#CommonModel.mergeCommonModels) + + + +### commonModel.getFromOriginalInput(key) ⇒ any +Retrieves data from originalInput by given key + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| key | given key | + + + +### commonModel.setType(type) +Set the types of the model + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | +| --- | +| type | + + + +### commonModel.removeType(types) +Removes type(s) from model type + +**Kind**: instance method of [CommonModel](#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](#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](#CommonModel) + +| Param | Description | +| --- | --- | +| propertyName | given property name | + + + +### commonModel.addItem(itemModel, originalInput) +Adds an item to the model. + +If items already exist the two are merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| itemModel | | +| originalInput | corresponding input that got interpreted to this model | + + + +### commonModel.addItemTuple(tupleModel, originalInput, index) +Adds a tuple to the model. + +If a item already exist it will be merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| tupleModel | | +| originalInput | corresponding input that got interpreted to this model | +| index | | + + + +### commonModel.addItemUnion(unionModel) +Adds a union model to the model. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | +| --- | +| unionModel | + + + +### commonModel.addEnum(enumValue) +Add enum value to the model. + +Ensures no duplicates are added. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | +| --- | +| enumValue | + + + +### commonModel.removeEnum(enumValue) +Remove enum from model. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | +| --- | +| enumValue | + + + +### commonModel.addProperty(propertyName, propertyModel, originalInput) +Adds a property to the model. +If the property already exist the two are merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| propertyName | | +| propertyModel | | +| originalInput | corresponding input that got interpreted to this model | + + + +### commonModel.addAdditionalProperty(additionalPropertiesModel, originalInput) +Adds additionalProperty to the model. +If another model already exist the two are merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| additionalPropertiesModel | | +| originalInput | corresponding input that got interpreted to this model corresponding input that got interpreted to this model | + + + +### commonModel.addPatternProperty(pattern, patternModel, originalInput) +Adds a patternProperty to the model. +If the pattern already exist the two models are merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| pattern | | +| patternModel | | +| originalInput | corresponding input that got interpreted to this model | + + + +### commonModel.addAdditionalItems(additionalItemsModel, originalInput) +Adds additionalItems to the model. +If another model already exist the two are merged. + +**Kind**: instance method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| additionalItemsModel | | +| originalInput | corresponding input that got interpreted to this 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](#CommonModel) + +| Param | +| --- | +| extendedModel | + + + +### CommonModel.toCommonModel(object) ⇒ +Takes a deep copy of the input object and converts it to an instance of CommonModel. + +**Kind**: static method of [CommonModel](#CommonModel) +**Returns**: CommonModel instance of the object + +| Param | Description | +| --- | --- | +| object | to transform | + + + +### CommonModel.mergeProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Merge two common model properties together + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +### CommonModel.mergeAdditionalProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Merge two common model additionalProperties together + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +### CommonModel.mergeAdditionalItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Merge two common model additionalItems together + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +### CommonModel.mergeItems(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Merge items together, prefer tuples over simple array since it is more strict. + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +### CommonModel.mergePatternProperties(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Merge two common model pattern properties together + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +### CommonModel.mergeTypes(mergeTo, mergeFrom) +Merge types together + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | +| --- | +| mergeTo | +| mergeFrom | + + + +### CommonModel.mergeCommonModels(mergeTo, mergeFrom, originalInput, alreadyIteratedModels) +Only merge if left side is undefined and right side is sat OR both sides are defined + +**Kind**: static method of [CommonModel](#CommonModel) + +| Param | Description | +| --- | --- | +| mergeTo | | +| mergeFrom | | +| originalInput | corresponding input that got interpreted to this model | +| alreadyIteratedModels | | + + + +## Draft4Schema +JSON Draft 4 schema model + +**Kind**: global class + + +### Draft4Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of Draft4Schema. + +**Kind**: static method of [Draft4Schema](#Draft4Schema) + +| Param | +| --- | +| object | + + + +## Draft6Schema +JSON Draft 6 schema model + +**Kind**: global class + + +### Draft6Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of Draft6Schema. + +**Kind**: static method of [Draft6Schema](#Draft6Schema) + +| Param | +| --- | +| object | + + + +## Draft7Schema +JSON Draft7Schema Draft 7 model + +**Kind**: global class + + +### Draft7Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of Draft7Schema. + +**Kind**: static method of [Draft7Schema](#Draft7Schema) + +| Param | +| --- | +| object | + + + +## InputMetaModel +Since each input processor can create multiple meta models this is a wrapper to a MetaModel to make that possible. + +**Kind**: global class + + +## 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 + +https://swagger.io/specification/#schema-object + +**Kind**: global class + + +### OpenapiV3Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of OpenapiV3Schema. + +**Kind**: static method of [OpenapiV3Schema](#OpenapiV3Schema) + +| Param | +| --- | +| object | + + + +## OutputModel +Common representation for the output model. + +**Kind**: global class + + +## RenderOutput +Common representation for the rendered output. + +**Kind**: global class + + +## 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 + +https://swagger.io/specification/v2/#schemaObject + +**Kind**: global class + + +### SwaggerV2Schema.toSchema(object) +Takes a deep copy of the input object and converts it to an instance of SwaggerV2Schema. + +**Kind**: static method of [SwaggerV2Schema](#SwaggerV2Schema) + +| Param | +| --- | +| object | + + + +## AsyncAPIInputProcessor +Class for processing AsyncAPI inputs + +**Kind**: global class + +* [AsyncAPIInputProcessor](#AsyncAPIInputProcessor) + * _instance_ + * [.process(input)](#AsyncAPIInputProcessor+process) + * [.shouldProcess(input)](#AsyncAPIInputProcessor+shouldProcess) + * [.tryGetVersionOfDocument(input)](#AsyncAPIInputProcessor+tryGetVersionOfDocument) + * _static_ + * [.isFromParser(input)](#AsyncAPIInputProcessor.isFromParser) + * [.isFromNewParser(input)](#AsyncAPIInputProcessor.isFromNewParser) + + + +### asyncAPIInputProcessor.process(input) +Process the input as an AsyncAPI document + +**Kind**: instance method of [AsyncAPIInputProcessor](#AsyncAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### asyncAPIInputProcessor.shouldProcess(input) +Figures out if an object is of type AsyncAPI document + +**Kind**: instance method of [AsyncAPIInputProcessor](#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](#AsyncAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### AsyncAPIInputProcessor.isFromParser(input) +Figure out if input is from the AsyncAPI parser. + +**Kind**: static method of [AsyncAPIInputProcessor](#AsyncAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### AsyncAPIInputProcessor.isFromNewParser(input) +Figure out if input is from the new AsyncAPI parser. + +**Kind**: static method of [AsyncAPIInputProcessor](#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](#InputProcessor) + * [.setProcessor(type, processor)](#InputProcessor+setProcessor) + * [.getProcessors()](#InputProcessor+getProcessors) ⇒ + * [.process(input, options)](#InputProcessor+process) + + + +### inputProcessor.setProcessor(type, processor) +Set a processor. + +**Kind**: instance method of [InputProcessor](#InputProcessor) + +| Param | Description | +| --- | --- | +| type | of processor | +| processor | | + + + +### inputProcessor.getProcessors() ⇒ +**Kind**: instance method of [InputProcessor](#InputProcessor) +**Returns**: all processors + + +### inputProcessor.process(input, options) +The processor code which delegates the processing to the correct implementation. + +**Kind**: instance method of [InputProcessor](#InputProcessor) + +| Param | Description | +| --- | --- | +| input | to process | +| options | passed to the processors | + + + +## JsonSchemaInputProcessor +Class for processing JSON Schema + +**Kind**: global class + +* [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + * _instance_ + * [.process(input)](#JsonSchemaInputProcessor+process) + * [.shouldProcess(input)](#JsonSchemaInputProcessor+shouldProcess) + * [.processDraft7(input)](#JsonSchemaInputProcessor+processDraft7) + * [.processDraft4(input)](#JsonSchemaInputProcessor+processDraft4) + * [.processDraft6(input)](#JsonSchemaInputProcessor+processDraft6) + * [.handleRootReference()](#JsonSchemaInputProcessor+handleRootReference) + * _static_ + * [.reflectSchemaNames(schema, namesStack, name, isRoot)](#JsonSchemaInputProcessor.reflectSchemaNames) + * [.ensureNamePattern(previousName, ...newParts)](#JsonSchemaInputProcessor.ensureNamePattern) + * [.convertSchemaToCommonModel(schema)](#JsonSchemaInputProcessor.convertSchemaToCommonModel) + + + +### jsonSchemaInputProcessor.process(input) +Function for processing a JSON Schema input. + +**Kind**: instance method of [JsonSchemaInputProcessor](#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](#JsonSchemaInputProcessor) + +| Param | +| --- | +| input | + + + +### jsonSchemaInputProcessor.processDraft7(input) +Process a draft-7 schema + +**Kind**: instance method of [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + +| Param | Description | +| --- | --- | +| input | to process as draft 7 | + + + +### jsonSchemaInputProcessor.processDraft4(input) +Process a draft-4 schema + +**Kind**: instance method of [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + +| Param | Description | +| --- | --- | +| input | to process as draft 4 | + + + +### jsonSchemaInputProcessor.processDraft6(input) +Process a draft-6 schema + +**Kind**: instance method of [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + +| Param | Description | +| --- | --- | +| input | to process as draft-6 | + + + +### jsonSchemaInputProcessor.handleRootReference() +This is a hotfix and really only a partial solution as it does not cover all cases. + +But it's the best we can do until we find or build a better library to handle references. + +**Kind**: instance method of [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + + +### JsonSchemaInputProcessor.reflectSchemaNames(schema, namesStack, name, isRoot) +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](#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](#JsonSchemaInputProcessor) + +| Param | Description | +| --- | --- | +| previousName | to concatenate with | +| ...newParts | | + + + +### JsonSchemaInputProcessor.convertSchemaToCommonModel(schema) +Simplifies a JSON Schema into a common models + +**Kind**: static method of [JsonSchemaInputProcessor](#JsonSchemaInputProcessor) + +| Param | Description | +| --- | --- | +| schema | to simplify to common model | + + + +## OpenAPIInputProcessor +Class for processing OpenAPI V3.0 inputs + +**Kind**: global class + +* [OpenAPIInputProcessor](#OpenAPIInputProcessor) + * _instance_ + * [.process(input)](#OpenAPIInputProcessor+process) + * [.shouldProcess(input)](#OpenAPIInputProcessor+shouldProcess) + * [.tryGetVersionOfDocument(input)](#OpenAPIInputProcessor+tryGetVersionOfDocument) + * _static_ + * [.convertToInternalSchema(schema, name)](#OpenAPIInputProcessor.convertToInternalSchema) + + + +### openAPIInputProcessor.process(input) +Process the input as a OpenAPI V3.0 document + +**Kind**: instance method of [OpenAPIInputProcessor](#OpenAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### openAPIInputProcessor.shouldProcess(input) +Figures out if an object is of type OpenAPI V3.0.x document and supported + +**Kind**: instance method of [OpenAPIInputProcessor](#OpenAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### openAPIInputProcessor.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 [OpenAPIInputProcessor](#OpenAPIInputProcessor) + +| Param | +| --- | +| input | + + + +### OpenAPIInputProcessor.convertToInternalSchema(schema, name) +Converts a schema to the internal schema format. + +**Kind**: static method of [OpenAPIInputProcessor](#OpenAPIInputProcessor) + +| Param | Description | +| --- | --- | +| schema | to convert | +| name | of the schema | + + + +## SwaggerInputProcessor +Class for processing Swagger inputs + +**Kind**: global class + +* [SwaggerInputProcessor](#SwaggerInputProcessor) + * _instance_ + * [.process(input)](#SwaggerInputProcessor+process) + * [.shouldProcess(input)](#SwaggerInputProcessor+shouldProcess) + * [.tryGetVersionOfDocument(input)](#SwaggerInputProcessor+tryGetVersionOfDocument) + * _static_ + * [.convertToInternalSchema(schema, name)](#SwaggerInputProcessor.convertToInternalSchema) + + + +### swaggerInputProcessor.process(input) +Process the input as a Swagger document + +**Kind**: instance method of [SwaggerInputProcessor](#SwaggerInputProcessor) + +| Param | +| --- | +| input | + + + +### swaggerInputProcessor.shouldProcess(input) +Figures out if an object is of type Swagger document and supported + +**Kind**: instance method of [SwaggerInputProcessor](#SwaggerInputProcessor) + +| Param | +| --- | +| input | + + + +### swaggerInputProcessor.tryGetVersionOfDocument(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](#SwaggerInputProcessor) + +| Param | +| --- | +| input | + + + +### SwaggerInputProcessor.convertToInternalSchema(schema, name) +Converts a Swagger 2.0 Schema to the internal schema format. + +**Kind**: static method of [SwaggerInputProcessor](#SwaggerInputProcessor) + +| Param | Description | +| --- | --- | +| schema | to convert | +| name | of the schema | + + + +## TemplateInputProcessor +Class for processing X input + +**Kind**: global class + + +## 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](#LoggerClass) + +| Param | Description | +| --- | --- | +| logger | to add | + + + +## convertToUnionModel() +Converts a CommonModel into multiple models wrapped in a union model. + +Because a CommonModel might contain multiple models, it's name for each of those models would be the same, instead we slightly change the model name. +Each model has it's type as a name prepended to the union name. + +If the CommonModel has multiple types + +**Kind**: global function + + +## isDictionary() +Determine whether we have a dictionary or an object. because in some cases inputs might be: +{ "type": "object", "additionalProperties": { "$ref": "#" } } which is to be interpreted as a dictionary not an object model. + +**Kind**: global function + + +## getOriginalInputFromAdditionalAndPatterns() +Return the original input based on additionalProperties and patternProperties. + +**Kind**: global function + + +## convertAdditionalAndPatterns() +Function creating the right meta model based on additionalProperties and patternProperties. + +**Kind**: global function + + +## NO\_DUPLICATE\_PROPERTIES(constrainedObjectModel, objectModel, propertyName, namingFormatter) +Because a lot of the other constrain functions (such as NO_NUMBER_START_CHAR, NO_EMPTY_VALUE, etc) they might manipulate the property names by append, prepend, or manipulate it any other way. +We then need to make sure that they don't clash with any existing properties, this is what this function handles. +If so, prepend `reserved_` to the property name and recheck. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| constrainedObjectModel | the current constrained object model, which contains already existing constrained properties | +| objectModel | the raw object model which is non-constrained to the output language. | +| propertyName | one of the properties in objectModel which might have been manipulated | +| namingFormatter | the name formatter which are used to format the property key | + + + +## NO\_DUPLICATE\_ENUM\_KEYS(constrainedEnumModel, enumModel, enumKey, namingFormatter, enumKeyToCheck, onNameChange, onNameChangeToCheck) ⇒ string +Because a lot of the other constrain functions (such as NO_NUMBER_START_CHAR, NO_EMPTY_VALUE, etc) they might manipulate the enum keys by append, prepend, or manipulate it any other way. +We then need to make sure that they don't clash with any existing enum keys, this is what this function handles. +If so, prepend `reserved_` to the enum key and recheck. + +**Kind**: global function +**Returns**: string - the potential new enum key that does not clash with existing enum keys. + +| Param | Description | +| --- | --- | +| constrainedEnumModel | the current constrained enum model, which contains already existing constrained enum keys | +| enumModel | the raw enum model which is non-constrained to the output language. | +| enumKey | one of the enum keys in enumModel which might have been manipulated. | +| namingFormatter | the name formatter which are used to format the enum key. | +| enumKeyToCheck | the enum key to use for checking if it already exist, defaults to enumKey. | +| onNameChange | callback to change the name of the enum key that needs to be returned. | +| onNameChangeToCheck | callback to change the enum key which is being checked as part of the existing models. | + + + +## renderJavaScriptDependency(toImport, fromModule, moduleSystem) +Function to make it easier to render JS/TS dependencies based on module system + +**Kind**: global function + +| Param | +| --- | +| toImport | +| fromModule | +| moduleSystem | + + + +## makeUnique(array) +Function to make an array of ConstrainedMetaModels only contain unique values (ignores different in memory instances) + +**Kind**: global function + +| Param | Description | +| --- | --- | +| array | to make unique | + + + +## lengthInUtf8Bytes() +Convert a string into utf-8 encoding and return the byte size. + +**Kind**: global function + + +## 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 + +**Kind**: global function + +| Param | Description | +| --- | --- | +| presets | the list to check | +| preset | the preset to check for | + + + +## trySplitModel(model, options, models) ⇒ +Try split the model + +**Kind**: global function +**Returns**: whether the new or old MetaModel to use. + +| Param | +| --- | +| model | +| options | +| models | + + + +## split(model, options, models) ⇒ +Overwrite the nested models with references where required. + +**Kind**: global function +**Returns**: an array of all the split models + +| Param | +| --- | +| model | +| options | +| models | + + + +## interpretAdditionalItems(schema, model, interpreter, interpreterOptions) +Interpreter function for additionalItems keyword. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretAdditionalProperties(schema, model, interpreter, interpreterOptions) +Interpreter function for additionalProperties keyword. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretAllOf(schema, model, interpreter, interpreterOptions) +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 | + + + +## interpretAnyOf(schema, model, interpreter, interpreterOptions) +Interpreter function for anyOf keyword. + +It puts the schema reference into the items field. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretConst(schema, model) +Interpreter function for const keyword for draft version > 4 + +**Kind**: global function + +| Param | +| --- | +| schema | +| model | + + + +## interpretDependencies(schema, model) +Interpreter function for dependencies keyword. + +**Kind**: global function + +| Param | +| --- | +| schema | +| model | + + + +## interpretEnum(schema, model) +Interpreter function for enum keyword + +**Kind**: global function + +| Param | +| --- | +| schema | +| model | + + + +## interpretItems(schema, model, interpreter, interpreterOptions) +Interpreter function for 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 not keyword. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretOneOf(schema, model, interpreter, interpreterOptions) +Interpreter function for oneOf keyword. + +It puts the schema reference into the items field. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretOneOfWithAllOf(schema, model, interpreter, interpreterOptions) +Interpreter function for oneOf keyword combined with the allOf keyword. + +It merges the allOf schemas into all of the oneOf schemas. Shared properties are merged. The oneOf schemas are then added as union to the model. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretOneOfWithProperties(schema, model, interpreter, interpreterOptions) +Interpreter function for oneOf keyword combined with properties. + +It merges the properties of the schema into the oneOf schemas. Shared properties are merged. The oneOf schemas are then added as union to the model. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## interpretPatternProperties(schema, model, interpreter, interpreterOptions) +Interpreter function for 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 properties keyword. + +**Kind**: global function + +| Param | Description | +| --- | --- | +| schema | | +| model | | +| interpreter | | +| interpreterOptions | to control the interpret process | + + + +## 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 | + + + +## isClass(obj) +Return true or false based on whether the input object is a regular object or a class + +Taken from: https://stackoverflow.com/a/43197340/6803886 + +**Kind**: global function + +| Param | +| --- | +| obj | + + + +## mergePartialAndDefault() +Merge a non optional value with custom optional values to form a full value that has all properties sat. + +**Kind**: global function diff --git a/docs/README.md b/docs/README.md index b5b61ed31d..2d8231e16a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,7 +15,6 @@ - [Interpretation of JSON Schema](#interpretation-of-json-schema) - [Migration](#migration) - [Coming from other tools](#coming-from-other-tools) -- [API Documentation](#api-documentation) - [Languages](#languages) @@ -57,10 +56,6 @@ As time goes on, major versions are inevitable and expected! You can find the mi ### [Coming from other tools](./other-tools.md) Contains specific information about the differences between a lot of other common model generation tools. -### [API Documentation](https://modelina.org/docs/api) - -No one wants to read the code to find information about it, instead use the [/docs/api](https://modelina.org/docs/api) page on the website to find what you are looking for! - ### Languages Each language has its own limitations, corner cases, and features; thus, each language has separate documentation. - [C#](./languages/Csharp.md) diff --git a/modelina-website/package.json b/modelina-website/package.json index c65f6001cc..0cd19c925e 100644 --- a/modelina-website/package.json +++ b/modelina-website/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "npm run build:examples && cross-env NODE_OPTIONS='--inspect' next dev", "build": "npm run build:examples && next build --no-lint", - "build:modelina": "cd .. && npm i && npm run build:prod && npm run docs:api", + "build:modelina": "cd .. && npm i && npm run build:prod", "export": "next export", "start": "next start", "lint": "next lint -c ./.eslintrc", diff --git a/modelina-website/src/components/layouts/Footer.tsx b/modelina-website/src/components/layouts/Footer.tsx index 34fd458060..a1f908b64f 100644 --- a/modelina-website/src/components/layouts/Footer.tsx +++ b/modelina-website/src/components/layouts/Footer.tsx @@ -10,7 +10,7 @@ import Heading from '../typography/Heading'; export default function Footer() { return ( -