Search in sources :

Example 1 with Oas30Header

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

the class Oas30DataModelReader method readEncoding.

/**
 * Reads an OAS 3.0 Encoding from the given js data.
 * @param json
 * @param node
 */
public void readEncoding(Object json, Oas30Encoding node) {
    String contentType = JsonCompat.consumePropertyString(json, Constants.PROP_CONTENT_TYPE);
    Object headers = JsonCompat.consumeProperty(json, Constants.PROP_HEADERS);
    String style = JsonCompat.consumePropertyString(json, Constants.PROP_STYLE);
    Boolean explode = JsonCompat.consumePropertyBoolean(json, Constants.PROP_EXPLODE);
    Boolean allowReserved = JsonCompat.consumePropertyBoolean(json, Constants.PROP_ALLOW_RESERVED);
    node.contentType = contentType;
    node.style = style;
    node.explode = explode;
    node.allowReserved = allowReserved;
    if (headers != null) {
        JsonCompat.keys(headers).forEach(name -> {
            Object header = JsonCompat.consumeProperty(headers, name);
            Oas30Header headerModel = node.createHeader(name);
            this.readHeader(header, headerModel);
            node.addHeader(name, headerModel);
        });
    }
    this.readExtensions(json, node);
    this.readExtraProperties(json, node);
}
Also used : Oas30Header(io.apicurio.datamodels.openapi.v3.models.Oas30Header)

Example 2 with Oas30Header

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

the class Oas30DataModelWriter method writeHeader.

/**
 * @see io.apicurio.datamodels.openapi.io.OasDataModelWriter#writeHeader(java.lang.Object, io.apicurio.datamodels.openapi.models.OasHeader)
 */
@Override
protected void writeHeader(Object json, OasHeader node) {
    Oas30Header header = (Oas30Header) node;
    JsonCompat.setPropertyString(json, Constants.PROP_$REF, header.$ref);
    JsonCompat.setPropertyBoolean(json, Constants.PROP_REQUIRED, header.required);
    JsonCompat.setPropertyBoolean(json, Constants.PROP_DEPRECATED, header.deprecated);
    JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_EMPTY_VALUE, header.allowEmptyValue);
    JsonCompat.setPropertyString(json, Constants.PROP_STYLE, header.style);
    JsonCompat.setPropertyBoolean(json, Constants.PROP_EXPLODE, header.explode);
    JsonCompat.setPropertyBoolean(json, Constants.PROP_ALLOW_RESERVED, header.allowReserved);
    JsonCompat.setPropertyNull(json, Constants.PROP_SCHEMA);
    JsonCompat.setProperty(json, Constants.PROP_EXAMPLE, header.example);
    JsonCompat.setPropertyNull(json, Constants.PROP_EXAMPLES);
    JsonCompat.setPropertyNull(json, Constants.PROP_CONTENT);
    super.writeHeader(json, node);
}
Also used : Oas30Header(io.apicurio.datamodels.openapi.v3.models.Oas30Header)

Example 3 with Oas30Header

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

the class OasHeaderSchemaContentMutualExclusivityRule method visitHeader.

/**
 * @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitHeader(io.apicurio.datamodels.openapi.models.OasHeader)
 */
@Override
public void visitHeader(OasHeader node) {
    Oas30Header header = (Oas30Header) node;
    this.reportIf(hasValue(header.schema) && hasContent(header), node, Constants.PROP_SCHEMA, map());
}
Also used : Oas30Header(io.apicurio.datamodels.openapi.v3.models.Oas30Header)

Example 4 with Oas30Header

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

the class OasUnexpectedNumberOfHeaderMTsRule method visitHeader.

/**
 * @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitHeader(io.apicurio.datamodels.openapi.models.OasHeader)
 */
@Override
public void visitHeader(OasHeader node) {
    Oas30Header header = (Oas30Header) node;
    this.reportIfInvalid(header.getMediaTypes().size() < 2, node, Constants.PROP_CONTENT, map());
}
Also used : Oas30Header(io.apicurio.datamodels.openapi.v3.models.Oas30Header)

Example 5 with Oas30Header

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

the class Oas20to30TransformationVisitor method visitHeader.

/**
 * @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitHeader(io.apicurio.datamodels.openapi.models.OasHeader)
 */
@Override
public void visitHeader(OasHeader node) {
    Oas30Response parent30 = (Oas30Response) this.lookup(node.parent());
    Oas30Header header30 = parent30.createHeader(node.getName());
    parent30.addHeader(node.getName(), header30);
    header30.description = node.description;
    header30.schema = this.toSchema(node, header30.createSchema(), false);
    this.mapNode(node, header30);
}
Also used : Oas30Response(io.apicurio.datamodels.openapi.v3.models.Oas30Response) Oas30Header(io.apicurio.datamodels.openapi.v3.models.Oas30Header)

Aggregations

Oas30Header (io.apicurio.datamodels.openapi.v3.models.Oas30Header)12 Oas30Response (io.apicurio.datamodels.openapi.v3.models.Oas30Response)3 Oas30Example (io.apicurio.datamodels.openapi.v3.models.Oas30Example)2 Oas30Link (io.apicurio.datamodels.openapi.v3.models.Oas30Link)2 Oas30MediaType (io.apicurio.datamodels.openapi.v3.models.Oas30MediaType)2 ModernSecurityScheme (io.apicurio.datamodels.core.models.common.ModernSecurityScheme)1 Oas30Callback (io.apicurio.datamodels.openapi.v3.models.Oas30Callback)1 Oas30CallbackDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30CallbackDefinition)1 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)1 Oas30ExampleDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30ExampleDefinition)1 Oas30HeaderDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30HeaderDefinition)1 Oas30LinkDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30LinkDefinition)1 Oas30Parameter (io.apicurio.datamodels.openapi.v3.models.Oas30Parameter)1 Oas30ParameterDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30ParameterDefinition)1 Oas30RequestBody (io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody)1 Oas30RequestBodyDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30RequestBodyDefinition)1 Oas30ResponseDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition)1 Oas30Schema (io.apicurio.datamodels.openapi.v3.models.Oas30Schema)1 Oas30SchemaDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30SchemaDefinition)1 Oas30SecurityScheme (io.apicurio.datamodels.openapi.v3.models.Oas30SecurityScheme)1