Search in sources :

Example 1 with OasResponse

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

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

the class AddResponseDefinitionCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[AddResponseDefinitionCommand] Executing.");
    OasDocument doc = (OasDocument) document;
    // Do nothing if the definition already exists.
    if (this.defExists(doc)) {
        LoggerCompat.info("[AddResponseDefinitionCommand] Definition with name %s already exists.", this._newDefinitionName);
        this._defExisted = true;
        return;
    }
    this.prepareDocumentForDef(doc);
    OasResponse definition = this.createResponseDefinition(doc);
    this.addDefinition(doc, definition);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Example 3 with OasResponse

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

the class Oas30Responses method createResponse.

/**
 * @see io.apicurio.datamodels.openapi.models.OasResponses#createResponse(java.lang.String)
 */
@Override
public OasResponse createResponse(String statusCode) {
    OasResponse response = new Oas30Response(statusCode);
    response._ownerDocument = this.ownerDocument();
    response._parent = this;
    return response;
}
Also used : OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Example 4 with OasResponse

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

the class Oas20Responses method createResponse.

/**
 * @see io.apicurio.datamodels.openapi.models.OasResponses#createResponse(java.lang.String)
 */
@Override
public OasResponse createResponse(String statusCode) {
    OasResponse response = new Oas20Response(statusCode);
    response._ownerDocument = this.ownerDocument();
    response._parent = this;
    return response;
}
Also used : OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Example 5 with OasResponse

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

the class OasDataModelWriter method visitResponseDefinition.

/**
 * @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitResponseDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
 */
@Override
public void visitResponseDefinition(IDefinition node) {
    OasResponse response = (OasResponse) node;
    Object parent = this.lookupParentJson(response);
    Object json = JsonCompat.objectNode();
    writeResponse(json, response);
    this.writeExtraProperties(json, response);
    addResponseDefinitionToParent(parent, json, node);
    this.updateIndex(response, json);
}
Also used : OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Aggregations

OasResponse (io.apicurio.datamodels.openapi.models.OasResponse)14 OasSchema (io.apicurio.datamodels.openapi.models.OasSchema)3 Map (java.util.Map)3 OasResponses (io.apicurio.datamodels.openapi.models.OasResponses)2 Server (io.apicurio.datamodels.core.models.common.Server)1 ServerVariable (io.apicurio.datamodels.core.models.common.ServerVariable)1 OasDocument (io.apicurio.datamodels.openapi.models.OasDocument)1 OasOperation (io.apicurio.datamodels.openapi.models.OasOperation)1 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)1 Oas30MediaType (io.apicurio.datamodels.openapi.v3.models.Oas30MediaType)1 Oas30Operation (io.apicurio.datamodels.openapi.v3.models.Oas30Operation)1 Oas30RequestBody (io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody)1 Oas30Response (io.apicurio.datamodels.openapi.v3.models.Oas30Response)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1