openapi_client.schemas

Methods and classes used to generate classes and other data structures representing common schemas in an OpenAPI Specification.

Members

Classes

JsonSchema
class JsonSchema

Descriptive information about a OpenAPI schema and the Dlang code that represents it.

Functions

generateClassCode
void generateClassCode(Appender!string buffer, string description, string className, OasSchema[string] properties)

Writes to a buffer a Dlang class representing an OpenAPI Specification schema.

generateModuleCode
void generateModuleCode(string targetDir, JsonSchema jsonSchema, OasSchema oasSchema, string packageRoot)

Writes a Dlang source file for a module that contains a class representing an OpenAPI Specification schema.

generatePropertyCode
void generatePropertyCode(Appender!string buffer, string propertyName, OasSchema propertySchema, string prefix)

Produce code for a class declaring a named property based on an OasSchema for the property.

generateSchemaInnerClasses
void generateSchemaInnerClasses(Appender!string buffer, OasSchema schema, string prefix, string defaultName, RedBlackTree!string context)

Some OasSchema types refer to unnamed objects that have a fixed set of parameters. The best representation of this in D is a named class.

getClassNameFromSchemaName
string getClassNameFromSchemaName(string schemaName)

In our code generation, the module is a file name which contains a class whose name is in CamelCase.

getModuleNameFromSchemaName
string getModuleNameFromSchemaName(string packageRoot, string schemaName)

Produce the full module name for a given schemaName and package.

getSchemaCodeType
string getSchemaCodeType(OasSchema schema, string defaultName)

Converts a given OasSchema type into the equivalent type in source code.

getSchemaNameFromRef
string getSchemaNameFromRef(string ref_)

Returns the OpenAPI Specification schema name from a schema reference. E.g. "#/components/schemas/Thing" => "Thing".

getSchemaReferences
string[] getSchemaReferences(OasSchema schema)

When using a schema, it may reference other external schemas which have to be imported into any module that uses them.

writeSchemaFiles
void writeSchemaFiles(OasDocument oasDocument, string targetDir, string packageRoot)

Generates and writes to disk D-language files that correspond to the OpenAPI Document's components/schemas data. Depending on the software architecture ideas being used, such files can be known as "model" or "dto" files.

Static functions

getVariableName
string getVariableName(string propertyName)

Not every propertyName to be found in an OpenAPI Specification Document can be used to a variable name in code. E.g. the name "scope" is a reserved word in D, and must be replaced with "scope_".

Static variables

RESERVED_WORDS
RedBlackTree!string RESERVED_WORDS;

A collection of variable names that cannot be used to generate Dlang code.

Variables

jsonSchemaByRef
JsonSchema[string] jsonSchemaByRef;
Undocumented in source.

See Also

Meta