Search in sources :

Example 1 with Oas20ResponseDefinitions

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

the class DeleteResponseDefinitionCommand_20 method doDeleteResponseDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doDeleteResponseDefinition(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected Object doDeleteResponseDefinition(Document document) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20ResponseDefinitions responses = doc20.responses;
    if (this.isNullOrUndefined(responses) || ModelUtils.isNullOrUndefined(responses.getResponse(this._definitionName))) {
        return null;
    }
    Oas20ResponseDefinition schemaDef = responses.removeResponse(this._definitionName);
    return Library.writeNode(schemaDef);
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20ResponseDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions) Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Example 2 with Oas20ResponseDefinitions

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

the class Oas20DataModelReader method readResponseDefinitions.

/**
 * Reads the response definitions.
 * @param json
 * @param node
 */
public void readResponseDefinitions(Object json, Oas20ResponseDefinitions node) {
    List<String> names = JsonCompat.keys(json);
    for (String name : names) {
        Object definition = JsonCompat.consumeProperty(json, name);
        Oas20ResponseDefinition definitionModel = node.createResponse(name);
        this.readResponseDefinition(definition, definitionModel);
        node.addResponse(name, definitionModel);
    }
}
Also used : Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Example 3 with Oas20ResponseDefinitions

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

the class DeleteResponseDefinitionCommand_20 method doRestoreResponseDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doRestoreResponseDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected void doRestoreResponseDefinition(Document document, Object oldDefinition) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20ResponseDefinitions responses = doc20.responses;
    if (this.isNullOrUndefined(responses)) {
        return;
    }
    Oas20ResponseDefinition definition = doc20.responses.createResponse(this._definitionName);
    Library.readNode(oldDefinition, definition);
    responses.addResponse(this._definitionName, definition);
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20ResponseDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions) Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Aggregations

Oas20ResponseDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)3 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)2 Oas20ResponseDefinitions (io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions)2