Search in sources :

Example 1 with AaiTag

use of io.apicurio.datamodels.asyncapi.models.AaiTag in project apicurio-data-models by Apicurio.

the class AaiDataModelReader method readMessageBase.

public void readMessageBase(Object json, AaiMessageBase node) {
    // headers
    Object jsonHeaders = JsonCompat.consumeProperty(json, Constants.PROP_HEADERS);
    if (jsonHeaders != null) {
        AaiHeaderItem headerModel = nodeFactory.createHeaderItem(node);
        this.readHeaderItem(jsonHeaders, headerModel);
        node.headers = headerModel;
    }
    // correlationId
    Object jsonCI = JsonCompat.consumeProperty(json, Constants.PROP_CORRELATION_ID);
    if (jsonCI != null) {
        AaiCorrelationId value = nodeFactory.createCorrelationId(node, null);
        this.readCorrelationId(jsonCI, value);
        node.correlationId = value;
    }
    // String properties
    node.schemaFormat = JsonCompat.consumePropertyString(json, Constants.PROP_SCHEMA_FORMAT);
    node.contentType = JsonCompat.consumePropertyString(json, Constants.PROP_CONTENT_TYPE);
    node.name = JsonCompat.consumePropertyString(json, Constants.PROP_NAME);
    node.title = JsonCompat.consumePropertyString(json, Constants.PROP_TITLE);
    node.summary = JsonCompat.consumePropertyString(json, Constants.PROP_SUMMARY);
    node.description = JsonCompat.consumePropertyString(json, Constants.PROP_DESCRIPTION);
    node.$ref = JsonCompat.consumePropertyString(json, Constants.PROP_$REF);
    // tags
    List<Object> jsonTags = JsonCompat.consumePropertyArray(json, Constants.PROP_TAGS);
    if (jsonTags != null) {
        jsonTags.forEach(j -> {
            AaiTag tag = nodeFactory.createTag(node);
            this.readTag(j, tag);
            node.addTag(tag);
        });
    }
    // external docs
    Object jsonED = JsonCompat.consumeProperty(json, Constants.PROP_EXTERNAL_DOCS);
    if (jsonED != null) {
        AaiExternalDocumentation value = nodeFactory.createExternalDocumentation(node);
        this.readExternalDocumentation(jsonED, value);
        node.externalDocs = value;
    }
    // bindings
    Object bindings = JsonCompat.consumeProperty(json, Constants.PROP_BINDINGS);
    if (bindings != null) {
        AaiMessageBindings bindingsModel = nodeFactory.createMessageBindings(node);
        this.readMessageBindings(bindings, bindingsModel);
        node.bindings = bindingsModel;
    }
    // examples
    List<Object> examples = JsonCompat.consumePropertyArray(json, Constants.PROP_EXAMPLES);
    if (examples != null) {
        List<Map<String, Object>> examplesList = new ArrayList<>();
        this.readMessageExamples(examples, examplesList);
        node.examples = examplesList;
    }
    this.readExtensions(json, node);
    this.readExtraProperties(json, node);
}
Also used : AaiExternalDocumentation(io.apicurio.datamodels.asyncapi.models.AaiExternalDocumentation) AaiTag(io.apicurio.datamodels.asyncapi.models.AaiTag) AaiHeaderItem(io.apicurio.datamodels.asyncapi.models.AaiHeaderItem) AaiMessageBindings(io.apicurio.datamodels.asyncapi.models.AaiMessageBindings) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) AaiCorrelationId(io.apicurio.datamodels.asyncapi.models.AaiCorrelationId)

Example 2 with AaiTag

use of io.apicurio.datamodels.asyncapi.models.AaiTag in project apicurio-data-models by Apicurio.

the class AaiDataModelReader method readOperationBase.

public void readOperationBase(Object json, AaiOperationBase node) {
    node.$ref = JsonCompat.consumePropertyString(json, Constants.PROP_$REF);
    // tags
    List<Object> jsonTags = JsonCompat.consumePropertyArray(json, Constants.PROP_TAGS);
    if (jsonTags != null) {
        jsonTags.forEach(j -> {
            AaiTag tag = nodeFactory.createTag(node);
            this.readTag(j, tag);
            node.addTag(tag);
        });
    }
    // bindings
    Object bindings = JsonCompat.consumeProperty(json, Constants.PROP_BINDINGS);
    if (bindings != null) {
        AaiOperationBindings operationBindingsModel = nodeFactory.createOperationBindings(node);
        this.readOperationBindings(bindings, operationBindingsModel);
        node.bindings = operationBindingsModel;
    }
    super.readOperation(json, node);
}
Also used : AaiTag(io.apicurio.datamodels.asyncapi.models.AaiTag) AaiOperationBindings(io.apicurio.datamodels.asyncapi.models.AaiOperationBindings)

Aggregations

AaiTag (io.apicurio.datamodels.asyncapi.models.AaiTag)2 AaiCorrelationId (io.apicurio.datamodels.asyncapi.models.AaiCorrelationId)1 AaiExternalDocumentation (io.apicurio.datamodels.asyncapi.models.AaiExternalDocumentation)1 AaiHeaderItem (io.apicurio.datamodels.asyncapi.models.AaiHeaderItem)1 AaiMessageBindings (io.apicurio.datamodels.asyncapi.models.AaiMessageBindings)1 AaiOperationBindings (io.apicurio.datamodels.asyncapi.models.AaiOperationBindings)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1