Search in sources :

Example 1 with Oas20Definitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20Definitions in project apicurio-data-models by Apicurio.

the class DeleteSchemaDefinitionCommand_20 method doRestoreSchemaDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSchemaDefinitionCommand#doRestoreSchemaDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected void doRestoreSchemaDefinition(Document document, Object oldDefinition) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20Definitions definitions = doc20.definitions;
    if (this.isNullOrUndefined(definitions)) {
        return;
    }
    Oas20SchemaDefinition definition = doc20.definitions.createSchemaDefinition(this._definitionName);
    Library.readNode(oldDefinition, definition);
    definitions.addDefinition(this._definitionName, definition);
}
Also used : Oas20Definitions(io.apicurio.datamodels.openapi.v2.models.Oas20Definitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SchemaDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)

Example 2 with Oas20Definitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20Definitions in project apicurio-data-models by Apicurio.

the class DeleteSchemaDefinitionCommand_20 method doDeleteSchemaDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSchemaDefinitionCommand#doDeleteSchemaDefinition(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected Object doDeleteSchemaDefinition(Document document) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20Definitions definitions = doc20.definitions;
    if (this.isNullOrUndefined(definitions)) {
        return null;
    }
    Oas20SchemaDefinition schemaDef = definitions.removeDefinition(this._definitionName);
    return Library.writeNode(schemaDef);
}
Also used : Oas20Definitions(io.apicurio.datamodels.openapi.v2.models.Oas20Definitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SchemaDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)

Example 3 with Oas20Definitions

use of io.apicurio.datamodels.openapi.v2.models.Oas20Definitions in project apicurio-data-models by Apicurio.

the class Oas20DataModelReader method readDefinitions.

/**
 * Reads the definitions.
 * @param json
 * @param node
 */
public void readDefinitions(Object json, Oas20Definitions node) {
    List<String> names = JsonCompat.keys(json);
    for (String name : names) {
        Object definition = JsonCompat.consumeProperty(json, name);
        Oas20SchemaDefinition definitionModel = node.createSchemaDefinition(name);
        this.readSchema(definition, definitionModel);
        node.addDefinition(name, definitionModel);
    }
}
Also used : Oas20SchemaDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)

Aggregations

Oas20SchemaDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)3 Oas20Definitions (io.apicurio.datamodels.openapi.v2.models.Oas20Definitions)2 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)2