use of io.apicurio.datamodels.openapi.v3.models.Oas30Encoding 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.Oas30Encoding in project apicurio-data-models by Apicurio.
the class Oas30DataModelReader method readMediaType.
/**
* Reads an OAS 3.0 Media Type from the given js data.
* @param json
* @param node
*/
public void readMediaType(Object json, Oas30MediaType node) {
Object schema = JsonCompat.consumeProperty(json, Constants.PROP_SCHEMA);
Object example = JsonCompat.consumePropertyObject(json, Constants.PROP_EXAMPLE);
Object examples = JsonCompat.consumeProperty(json, Constants.PROP_EXAMPLES);
Object encodings = JsonCompat.consumeProperty(json, Constants.PROP_ENCODING);
node.example = example;
if (schema != null) {
node.schema = node.createSchema();
this.readSchema(schema, node.schema);
}
if (examples != null) {
JsonCompat.keys(examples).forEach(name -> {
Object exx = JsonCompat.consumeProperty(examples, name);
Oas30Example exampleModel = (Oas30Example) node.createExample(name);
this.readExample(exx, exampleModel);
node.addExample(exampleModel);
});
}
if (encodings != null) {
JsonCompat.keys(encodings).forEach(name -> {
Object encoding = JsonCompat.consumeProperty(encodings, name);
Oas30Encoding encodingModel = node.createEncoding(name);
this.readEncoding(encoding, encodingModel);
node.addEncoding(name, encodingModel);
});
}
this.readExtensions(json, node);
this.readExtraProperties(json, node);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Encoding in project apicurio-data-models by Apicurio.
the class OasAllowReservedNotAllowedRule method visitEncoding.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitEncoding(io.apicurio.datamodels.openapi.v3.models.Oas30Encoding)
*/
@Override
public void visitEncoding(Oas30Encoding node) {
if (hasValue(node.allowReserved)) {
Oas30MediaType mediaType = (Oas30MediaType) node.parent();
this.reportIf(!equals(mediaType.getName(), "application/x-www-form-urlencoded"), node, Constants.PROP_ALLOW_RESERVED, map("name", mediaType.getName()));
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Encoding in project apicurio-data-models by Apicurio.
the class OasEncodingStyleNotAllowedRule method visitEncoding.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitEncoding(io.apicurio.datamodels.openapi.v3.models.Oas30Encoding)
*/
@Override
public void visitEncoding(Oas30Encoding node) {
if (hasValue(node.style)) {
Oas30MediaType mediaType = (Oas30MediaType) node.parent();
this.reportIfInvalid(mediaType.getName().indexOf("application/x-www-form-urlencoded") == 0, node, Constants.PROP_STYLE, map("name", mediaType.getName()));
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Encoding in project apicurio-data-models by Apicurio.
the class OasUnmatchedEncodingPropertyRule method visitEncoding.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitEncoding(io.apicurio.datamodels.openapi.v3.models.Oas30Encoding)
*/
@Override
public void visitEncoding(Oas30Encoding node) {
String name = node.getName();
OasSchema schema = ((Oas30MediaType) (node.parent())).schema;
this.reportIfInvalid(isValidSchemaProperty(schema, name), node, name, map("name", name));
}
Aggregations