Search in sources :

Example 1 with Oas20ResponseDefinition

use of io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition 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 Oas20ResponseDefinition

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

the class AddResponseDefinitionCommand_20 method addDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#addDefinition(io.apicurio.datamodels.openapi.models.OasDocument, io.apicurio.datamodels.openapi.models.OasResponse)
 */
@Override
protected void addDefinition(OasDocument document, OasResponse definition) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20ResponseDefinition def20 = (Oas20ResponseDefinition) definition;
    doc20.responses.addResponse(this._newDefinitionName, def20);
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Example 3 with Oas20ResponseDefinition

use of io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition 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 4 with Oas20ResponseDefinition

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

the class ReplaceResponseDefinitionCommand_20 method readNode.

/**
 * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#readNode(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected Oas20ResponseDefinition readNode(Document doc, Object node) {
    Oas20Document doc20 = (Oas20Document) doc;
    Oas20ResponseDefinition definition = doc20.responses.createResponse(this._defName);
    Library.readNode(node, definition);
    return definition;
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Example 5 with Oas20ResponseDefinition

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

the class ReplaceResponseDefinitionCommand_20 method addNode.

/**
 * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#addNode(io.apicurio.datamodels.core.models.Document, io.apicurio.datamodels.core.models.Node)
 */
@Override
protected void addNode(Document doc, Oas20ResponseDefinition node) {
    Oas20Document doc20 = (Oas20Document) doc;
    node._ownerDocument = doc20;
    node._parent = doc20.responses;
    doc20.responses.addResponse(node.getName(), node);
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document)

Aggregations

Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)10 Oas20ResponseDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)9 Oas20ResponseDefinitions (io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions)2 Oas20Parameter (io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)1 Oas20ParameterDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinition)1 Oas20Response (io.apicurio.datamodels.openapi.v2.models.Oas20Response)1 Oas20Schema (io.apicurio.datamodels.openapi.v2.models.Oas20Schema)1 Oas20SchemaDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)1