Search in sources :

Example 1 with AaiOperation

use of io.apicurio.datamodels.asyncapi.models.AaiOperation in project carbon-apimgt by wso2.

the class AsyncApiParser method buildWSUriMapping.

public Map<String, String> buildWSUriMapping(String apiDefinition) {
    Map<String, String> wsUriMapping = new HashMap<>();
    Aai20Document document = (Aai20Document) Library.readDocumentFromJSONString(apiDefinition);
    for (Map.Entry<String, AaiChannelItem> entry : document.channels.entrySet()) {
        AaiOperation publishOperation = entry.getValue().publish;
        if (publishOperation != null) {
            Extension xUriMapping = publishOperation.getExtension("x-uri-mapping");
            if (xUriMapping != null) {
                wsUriMapping.put("PUBLISH_" + entry.getKey(), xUriMapping.value.toString());
            }
        }
        AaiOperation subscribeOperation = entry.getValue().subscribe;
        if (subscribeOperation != null) {
            Extension xUriMapping = subscribeOperation.getExtension("x-uri-mapping");
            if (xUriMapping != null) {
                wsUriMapping.put("SUBSCRIBE_" + entry.getKey(), xUriMapping.value.toString());
            }
        }
    }
    return wsUriMapping;
}
Also used : Extension(io.apicurio.datamodels.core.models.Extension) AaiOperation(io.apicurio.datamodels.asyncapi.models.AaiOperation) AaiChannelItem(io.apicurio.datamodels.asyncapi.models.AaiChannelItem) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

AaiChannelItem (io.apicurio.datamodels.asyncapi.models.AaiChannelItem)1 AaiOperation (io.apicurio.datamodels.asyncapi.models.AaiOperation)1 Aai20Document (io.apicurio.datamodels.asyncapi.v2.models.Aai20Document)1 Extension (io.apicurio.datamodels.core.models.Extension)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1