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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations