Search in sources :

Example 1 with OasResponses

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

the class DeleteResponseCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[DeleteResponseCommand] Reverting.");
    if (this.isNullOrUndefined(this._oldResponse)) {
        return;
    }
    OasResponses responses = (OasResponses) this._responsesPath.resolve(document);
    if (this.isNullOrUndefined(responses)) {
        return;
    }
    OasResponse response = responses.createResponse(this._responseCode);
    Library.readNode(this._oldResponse, response);
    if (this.isNullOrUndefined(this._responseCode)) {
        responses.default_ = response;
    } else {
        responses.addResponse(this._responseCode, response);
    }
}
Also used : OasResponses(io.apicurio.datamodels.openapi.models.OasResponses) OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Example 2 with OasResponses

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

the class Oas20Operation method createResponses.

/**
 * @see io.apicurio.datamodels.openapi.models.OasOperation#createResponses()
 */
@Override
public OasResponses createResponses() {
    OasResponses responses = new Oas20Responses();
    responses._ownerDocument = this.ownerDocument();
    responses._parent = this;
    return responses;
}
Also used : OasResponses(io.apicurio.datamodels.openapi.models.OasResponses)

Example 3 with OasResponses

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

the class Oas30Operation method createResponses.

/**
 * @see io.apicurio.datamodels.openapi.models.OasOperation#createResponses()
 */
@Override
public OasResponses createResponses() {
    OasResponses responses = new Oas30Responses();
    responses._ownerDocument = this.ownerDocument();
    responses._parent = this;
    return responses;
}
Also used : OasResponses(io.apicurio.datamodels.openapi.models.OasResponses)

Example 4 with OasResponses

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

the class DeleteAllResponsesCommand method readNode.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteNodeCommand#readNode(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected OasResponses readNode(Document doc, Object node) {
    OasOperation operation = (OasOperation) this._parentPath.resolve(doc);
    OasResponses responses = operation.createResponses();
    Library.readNode(node, responses);
    return responses;
}
Also used : OasOperation(io.apicurio.datamodels.openapi.models.OasOperation) OasResponses(io.apicurio.datamodels.openapi.models.OasResponses)

Example 5 with OasResponses

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

the class DeleteResponseCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[DeleteResponseCommand] Executing.");
    this._oldResponse = null;
    OasResponse response = (OasResponse) this._responsePath.resolve(document);
    if (this.isNullOrUndefined(response)) {
        return;
    }
    OasResponses responses = (OasResponses) response.parent();
    if (this.isNullOrUndefined(this._responseCode)) {
        responses.default_ = null;
    } else {
        responses.removeResponse(this._responseCode);
    }
    this._oldResponse = Library.writeNode(response);
}
Also used : OasResponse(io.apicurio.datamodels.openapi.models.OasResponse) OasResponses(io.apicurio.datamodels.openapi.models.OasResponses)

Aggregations

OasResponses (io.apicurio.datamodels.openapi.models.OasResponses)5 OasResponse (io.apicurio.datamodels.openapi.models.OasResponse)2 OasOperation (io.apicurio.datamodels.openapi.models.OasOperation)1