diff --git a/pom.xml b/pom.xml index 5feb8a1c..8cc47f36 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 3.3.0 1.15.0 1.7.0 - 1.0.14.Final + 1.1.1.Final 3.1.1.RedHat diff --git a/src/main/java/io/apicurio/datamodels/Library.java b/src/main/java/io/apicurio/datamodels/Library.java index 40c2017c..8bf9180a 100755 --- a/src/main/java/io/apicurio/datamodels/Library.java +++ b/src/main/java/io/apicurio/datamodels/Library.java @@ -104,7 +104,7 @@ public static Document readDocumentFromJSONString(String jsonString) { /** * Called to serialize a given data model node to a JSON object. - * @param node + * @param document */ public static ObjectNode writeDocument(Document document) { ModelWriter writer = ModelWriterFactory.createModelWriter(document.root().modelType()); @@ -186,7 +186,7 @@ public static NodePath createNodePath(Node node) { /** * Called to create a node path instance for a stringified node path. - * @param node + * @param path */ public static NodePath parseNodePath(String path) { return NodePathUtil.parseNodePath(path); diff --git a/src/main/java/io/apicurio/datamodels/ModelTypeDetector.java b/src/main/java/io/apicurio/datamodels/ModelTypeDetector.java index 08fdf85e..90b94e35 100755 --- a/src/main/java/io/apicurio/datamodels/ModelTypeDetector.java +++ b/src/main/java/io/apicurio/datamodels/ModelTypeDetector.java @@ -39,6 +39,8 @@ public static ModelType discoverModelType(ObjectNode json) { return ModelType.ASYNCAPI25; } else if (asyncapi.startsWith("2.6")) { return ModelType.ASYNCAPI26; + } else if (asyncapi.startsWith("3.0")) { + return ModelType.ASYNCAPI30; } else { throw new RuntimeException("Unknown/unsupported AsyncAPI version: " + asyncapi); } diff --git a/src/main/java/io/apicurio/datamodels/VisitorUtil.java b/src/main/java/io/apicurio/datamodels/VisitorUtil.java index 07d70393..41043b2b 100755 --- a/src/main/java/io/apicurio/datamodels/VisitorUtil.java +++ b/src/main/java/io/apicurio/datamodels/VisitorUtil.java @@ -25,6 +25,7 @@ import io.apicurio.datamodels.models.asyncapi.v24.visitors.AsyncApi24Traverser; import io.apicurio.datamodels.models.asyncapi.v25.visitors.AsyncApi25Traverser; import io.apicurio.datamodels.models.asyncapi.v26.visitors.AsyncApi26Traverser; +import io.apicurio.datamodels.models.asyncapi.v30.visitors.AsyncApi30Traverser; import io.apicurio.datamodels.models.openapi.v20.visitors.OpenApi20Traverser; import io.apicurio.datamodels.models.openapi.v30.visitors.OpenApi30Traverser; import io.apicurio.datamodels.models.openapi.v31.visitors.OpenApi31Traverser; @@ -65,6 +66,9 @@ public static void visitTree(Node node, Visitor visitor, TraverserDirection dire case ASYNCAPI26: traverser = new AsyncApi26Traverser(visitor); break; + case ASYNCAPI30: + traverser = new AsyncApi30Traverser(visitor); + break; case OPENAPI20: traverser = new OpenApi20Traverser(visitor); break; diff --git a/src/main/java/io/apicurio/datamodels/transform/ExternalDocsCreator.java b/src/main/java/io/apicurio/datamodels/transform/ExternalDocsCreator.java index bb07ffb5..79cdf0ea 100755 --- a/src/main/java/io/apicurio/datamodels/transform/ExternalDocsCreator.java +++ b/src/main/java/io/apicurio/datamodels/transform/ExternalDocsCreator.java @@ -5,6 +5,8 @@ import io.apicurio.datamodels.models.Operation; import io.apicurio.datamodels.models.Schema; import io.apicurio.datamodels.models.Tag; +import io.apicurio.datamodels.models.openapi.OpenApiDocument; +import io.apicurio.datamodels.models.openapi.OpenApiExternalDocumentation; import io.apicurio.datamodels.models.visitors.CombinedVisitorAdapter; public class ExternalDocsCreator extends CombinedVisitorAdapter { @@ -19,8 +21,8 @@ public void visitSchema(Schema node) { @Override public void visitDocument(Document node) { - externalDocs = node.createExternalDocumentation(); - node.setExternalDocs(externalDocs); + externalDocs = ((OpenApiDocument) node).createExternalDocumentation(); + ((OpenApiDocument) node).setExternalDocs((OpenApiExternalDocumentation) externalDocs); } @Override diff --git a/src/main/java/io/apicurio/datamodels/transform/OpenApi20to30TransformationVisitor.java b/src/main/java/io/apicurio/datamodels/transform/OpenApi20to30TransformationVisitor.java index 180c1db4..071d9803 100755 --- a/src/main/java/io/apicurio/datamodels/transform/OpenApi20to30TransformationVisitor.java +++ b/src/main/java/io/apicurio/datamodels/transform/OpenApi20to30TransformationVisitor.java @@ -45,11 +45,13 @@ import io.apicurio.datamodels.models.Tag; import io.apicurio.datamodels.models.openapi.OpenApiExample; import io.apicurio.datamodels.models.openapi.OpenApiHeader; +import io.apicurio.datamodels.models.openapi.OpenApiOAuthFlow; import io.apicurio.datamodels.models.openapi.OpenApiPathItem; import io.apicurio.datamodels.models.openapi.OpenApiPaths; import io.apicurio.datamodels.models.openapi.OpenApiResponse; import io.apicurio.datamodels.models.openapi.OpenApiResponses; import io.apicurio.datamodels.models.openapi.OpenApiSchema; +import io.apicurio.datamodels.models.openapi.OpenApiTag; import io.apicurio.datamodels.models.openapi.OpenApiXML; import io.apicurio.datamodels.models.openapi.v20.OpenApi20Contact; import io.apicurio.datamodels.models.openapi.v20.OpenApi20Definitions; @@ -139,7 +141,7 @@ public OpenApi30Document getResult() { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitDocument(io.apicurio.datamodels.core.models.Document) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitDocument(Document) */ @Override public void visitDocument(Document node) { @@ -176,7 +178,7 @@ public void visitDocument(Document node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitInfo(io.apicurio.datamodels.core.models.common.Info) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitInfo(Info) */ @Override public void visitInfo(Info node) { @@ -194,7 +196,7 @@ public void visitInfo(Info node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitContact(io.apicurio.datamodels.core.models.common.Contact) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitContact(Contact) */ @Override public void visitContact(Contact node) { @@ -210,7 +212,7 @@ public void visitContact(Contact node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitLicense(io.apicurio.datamodels.core.models.common.License) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitLicense(License) */ @Override public void visitLicense(License node) { @@ -249,7 +251,7 @@ public void visitPathItem(OpenApiPathItem node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitOperation(io.apicurio.datamodels.core.models.common.Operation) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitOperation(Operation) */ @Override public void visitOperation(Operation node) { @@ -311,7 +313,7 @@ public void visitOperation(Operation node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitParameter(io.apicurio.datamodels.core.models.common.Parameter) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitParameter(Parameter) */ @Override public void visitParameter(Parameter node) { @@ -484,7 +486,7 @@ public void visitParameterDefinition(Parameter node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitExternalDocumentation(io.apicurio.datamodels.core.models.common.ExternalDocumentation) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitExternalDocumentation(ExternalDocumentation) */ @Override public void visitExternalDocumentation(ExternalDocumentation node) { @@ -501,9 +503,6 @@ public void visitExternalDocumentation(ExternalDocumentation node) { this.mapNode(node, externalDocs30); } - /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement) - */ @Override public void visitSecurityRequirement(SecurityRequirement node) { OpenApi20SecurityRequirement req = (OpenApi20SecurityRequirement) node; @@ -598,7 +597,7 @@ private void transformResponse(OpenApi20Response node, OpenApi30Response respons } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitSchema(io.apicurio.datamodels.core.models.common.Schema) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitSchema(Schema) */ @Override public void visitSchema(Schema node) { @@ -620,9 +619,6 @@ public void visitSchema(Schema node) { } } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitHeaders(io.apicurio.datamodels.openapi.v2.models.OpenApi20Headers) - */ @Override public void visitHeaders(OpenApi20Headers node) { OpenApi30Response parent30 = (OpenApi30Response) this.lookup(node.parent()); @@ -652,9 +648,6 @@ public void visitExample(OpenApiExample node) { // Examples are processed as part of "transformResponse" } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitItems(io.apicurio.datamodels.openapi.v2.models.OpenApi20Items) - */ @Override public void visitItems(OpenApi20Items node) { OpenApi30Schema parent30 = this.findItemsParent(node); @@ -667,28 +660,25 @@ public void visitItems(OpenApi20Items node) { } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitTag(io.apicurio.datamodels.core.models.common.Tag) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitTag(Tag) */ @Override public void visitTag(Tag node) { OpenApi30Document parent30 = this.doc30; - Tag tag30 = parent30.createTag(); + OpenApiTag tag30 = parent30.createTag(); tag30.setName(node.getName()); tag30.setDescription(node.getDescription()); parent30.addTag(tag30); this.mapNode(node, tag30); } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitSecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.OpenApi20SecurityDefinitions) - */ @Override public void visitSecurityDefinitions(OpenApi20SecurityDefinitions node) { // OpenAPI 3 has no "Security Definitions" wrapper entity. } /** - * @see io.apicurio.datamodels.models.visitors.Visitor#visitSecurityScheme(io.apicurio.datamodels.core.models.common.SecurityScheme) + * @see io.apicurio.datamodels.models.visitors.Visitor#visitSecurityScheme(SecurityScheme) */ @Override public void visitSecurityScheme(SecurityScheme node) { @@ -710,9 +700,9 @@ public void visitSecurityScheme(SecurityScheme node) { flows30.setImplicit(flows30.createOAuthFlow()); flows30.getImplicit().setAuthorizationUrl(scheme.getAuthorizationUrl()); if (!NodeUtil.isNullOrUndefined(scheme.getScopes())) { - flows30.getImplicit().setScopes(new LinkedHashMap<>()); + ((OpenApiOAuthFlow) flows30.getImplicit()).setScopes(new LinkedHashMap<>()); scheme.getScopes().getItemNames().forEach(scopeName -> { - flows30.getImplicit().getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); + ((OpenApiOAuthFlow) flows30.getImplicit()).getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); }); } } @@ -722,9 +712,9 @@ public void visitSecurityScheme(SecurityScheme node) { flows30.getAuthorizationCode().setAuthorizationUrl(scheme.getAuthorizationUrl()); flows30.getAuthorizationCode().setTokenUrl(scheme.getTokenUrl()); if (!NodeUtil.isNullOrUndefined(scheme.getScopes())) { - flows30.getAuthorizationCode().setScopes(new LinkedHashMap<>()); + ((OpenApiOAuthFlow) flows30.getAuthorizationCode()).setScopes(new LinkedHashMap<>()); scheme.getScopes().getItemNames().forEach(scopeName -> { - flows30.getAuthorizationCode().getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); + ((OpenApiOAuthFlow) flows30.getAuthorizationCode()).getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); }); } } @@ -733,9 +723,9 @@ public void visitSecurityScheme(SecurityScheme node) { flows30.setPassword(flows30.createOAuthFlow()); flows30.getPassword().setTokenUrl(scheme.getTokenUrl()); if (!NodeUtil.isNullOrUndefined(scheme.getScopes())) { - flows30.getPassword().setScopes(new LinkedHashMap<>()); + ((OpenApiOAuthFlow) flows30.getPassword()).setScopes(new LinkedHashMap<>()); scheme.getScopes().getItemNames().forEach(scopeName -> { - flows30.getPassword().getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); + ((OpenApiOAuthFlow) flows30.getPassword()).getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); }); } } @@ -744,9 +734,9 @@ public void visitSecurityScheme(SecurityScheme node) { flows30.setClientCredentials(flows30.createOAuthFlow()); flows30.getClientCredentials().setTokenUrl(scheme.getTokenUrl()); if (!NodeUtil.isNullOrUndefined(scheme.getScopes())) { - flows30.getClientCredentials().setScopes(new LinkedHashMap<>()); + ((OpenApiOAuthFlow) flows30.getClientCredentials()).setScopes(new LinkedHashMap<>()); scheme.getScopes().getItemNames().forEach(scopeName -> { - flows30.getClientCredentials().getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); + ((OpenApiOAuthFlow) flows30.getClientCredentials()).getScopes().put(scopeName, scheme.getScopes().getItem(scopeName)); }); } } @@ -755,9 +745,6 @@ public void visitSecurityScheme(SecurityScheme node) { this.mapNode(scheme, scheme30); } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitScopes(io.apicurio.datamodels.openapi.v2.models.OpenApi20Scopes) - */ @Override public void visitScopes(OpenApi20Scopes node) { // Note: scopes are handled during the processing of the security scheme. See `visitSecurityScheme` for details. @@ -850,25 +837,16 @@ public void visitItemsSchema(OpenApiSchema node) { this.mapNode(node, items30); } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitDefinitions(io.apicurio.datamodels.openapi.v2.models.OpenApi20Definitions) - */ @Override public void visitDefinitions(OpenApi20Definitions node) { // Note: there is no "definitions" entity in 3.0, so nothing to do here. } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitParameterDefinitions(io.apicurio.datamodels.openapi.v2.models.OpenApi20ParameterDefinitions) - */ @Override public void visitParameterDefinitions(OpenApi20ParameterDefinitions node) { // Note: there is no "parameters definitions" entity in 3.0, so nothing to do here. } - /** - * @see io.apicurio.datamodels.openapi.v2.visitors.IOpenApi20Visitor#visitResponseDefinitions(io.apicurio.datamodels.openapi.v2.models.OpenApi20ResponseDefinitions) - */ @Override public void visitResponseDefinitions(OpenApi20ResponseDefinitions node) { // Note: there is no "responses definitions" entity in 3.0, so nothing to do here. diff --git a/src/main/java/io/apicurio/datamodels/transform/SecurityRequirementCreator.java b/src/main/java/io/apicurio/datamodels/transform/SecurityRequirementCreator.java index 56e18be8..336230f5 100755 --- a/src/main/java/io/apicurio/datamodels/transform/SecurityRequirementCreator.java +++ b/src/main/java/io/apicurio/datamodels/transform/SecurityRequirementCreator.java @@ -6,6 +6,20 @@ import io.apicurio.datamodels.models.Server; import io.apicurio.datamodels.models.asyncapi.AsyncApiSecurityRequirement; import io.apicurio.datamodels.models.asyncapi.AsyncApiServer; +import io.apicurio.datamodels.models.asyncapi.v20.AsyncApi20SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v20.AsyncApi20Server; +import io.apicurio.datamodels.models.asyncapi.v21.AsyncApi21SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v21.AsyncApi21Server; +import io.apicurio.datamodels.models.asyncapi.v22.AsyncApi22SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v22.AsyncApi22Server; +import io.apicurio.datamodels.models.asyncapi.v23.AsyncApi23SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v23.AsyncApi23Server; +import io.apicurio.datamodels.models.asyncapi.v24.AsyncApi24SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v24.AsyncApi24Server; +import io.apicurio.datamodels.models.asyncapi.v25.AsyncApi25SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v25.AsyncApi25Server; +import io.apicurio.datamodels.models.asyncapi.v26.AsyncApi26SecurityRequirement; +import io.apicurio.datamodels.models.asyncapi.v26.AsyncApi26Server; import io.apicurio.datamodels.models.openapi.OpenApiDocument; import io.apicurio.datamodels.models.openapi.OpenApiOperation; import io.apicurio.datamodels.models.openapi.OpenApiSecurityRequirement; @@ -25,8 +39,9 @@ public void visitDocument(Document node) { @Override public void visitServer(Server node) { AsyncApiServer server = (AsyncApiServer) node; - securityRequirement = server.createSecurityRequirement(); - server.addSecurity((AsyncApiSecurityRequirement) securityRequirement); + AsyncApiSecurityRequirementParent srp = new AsyncApiSecurityRequirementParent(server); + securityRequirement = srp.createSecurityRequirement(); + srp.addSecurity((AsyncApiSecurityRequirement) securityRequirement); } @Override @@ -36,4 +51,68 @@ public void visitOperation(Operation node) { op.addSecurity((OpenApiSecurityRequirement) securityRequirement); } + /** + * Note: this is ugly and needed because AsyncApi 3 removed security requirements. The generated + * data model is not very good when commonalities between the versions of specs are not present. I + * think we need improvements in the generated data model. Perhaps we can generate XyzParent + * interfaces for properties? Maybe only when necessary? I'm open to other ideas. + */ + private class AsyncApiSecurityRequirementParent { + AsyncApiServer server; + + private AsyncApiSecurityRequirementParent(AsyncApiServer server) { + this.server = server; + } + + public AsyncApiSecurityRequirement createSecurityRequirement() { + if (server instanceof AsyncApi20Server) { + return ((AsyncApi20Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi21Server) { + return ((AsyncApi21Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi22Server) { + return ((AsyncApi22Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi23Server) { + return ((AsyncApi23Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi24Server) { + return ((AsyncApi24Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi25Server) { + return ((AsyncApi25Server) server).createSecurityRequirement(); + } + if (server instanceof AsyncApi26Server) { + return ((AsyncApi26Server) server).createSecurityRequirement(); + } + return null; + } + + public void addSecurity(AsyncApiSecurityRequirement securityRequirement) { + if (server instanceof AsyncApi20Server) { + ((AsyncApi20Server) server).addSecurity((AsyncApi20SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi21Server) { + ((AsyncApi21Server) server).addSecurity((AsyncApi21SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi22Server) { + ((AsyncApi22Server) server).addSecurity((AsyncApi22SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi23Server) { + ((AsyncApi23Server) server).addSecurity((AsyncApi23SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi24Server) { + ((AsyncApi24Server) server).addSecurity((AsyncApi24SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi25Server) { + ((AsyncApi25Server) server).addSecurity((AsyncApi25SecurityRequirement) securityRequirement); + } + if (server instanceof AsyncApi26Server) { + ((AsyncApi26Server) server).addSecurity((AsyncApi26SecurityRequirement) securityRequirement); + } + } + + } + } diff --git a/src/main/java/io/apicurio/datamodels/util/ModelTypeUtil.java b/src/main/java/io/apicurio/datamodels/util/ModelTypeUtil.java index 73ad787c..7af9aadc 100755 --- a/src/main/java/io/apicurio/datamodels/util/ModelTypeUtil.java +++ b/src/main/java/io/apicurio/datamodels/util/ModelTypeUtil.java @@ -25,6 +25,8 @@ public static String getVersion(ModelType type) { return "2.5.0"; case ASYNCAPI26: return "2.6.0"; + case ASYNCAPI30: + return "3.0.0"; case OPENAPI20: return "2.0"; case OPENAPI30: @@ -56,6 +58,31 @@ public static boolean isAsyncApiModel(Node node) { case ASYNCAPI24: case ASYNCAPI25: case ASYNCAPI26: + case ASYNCAPI30: + return true; + default: + return false; + } + } + + public static boolean isAsyncApi2Model(Node node) { + switch (node.root().modelType()) { + case ASYNCAPI20: + case ASYNCAPI21: + case ASYNCAPI22: + case ASYNCAPI23: + case ASYNCAPI24: + case ASYNCAPI25: + case ASYNCAPI26: + return true; + default: + return false; + } + } + + public static boolean isAsyncApi3Model(Node node) { + switch (node.root().modelType()) { + case ASYNCAPI30: return true; default: return false; diff --git a/src/main/java/io/apicurio/datamodels/validation/rules/invalid/format/InvalidServerUrlRule.java b/src/main/java/io/apicurio/datamodels/validation/rules/invalid/format/InvalidServerUrlRule.java index 3dfe62a3..c799dbd4 100755 --- a/src/main/java/io/apicurio/datamodels/validation/rules/invalid/format/InvalidServerUrlRule.java +++ b/src/main/java/io/apicurio/datamodels/validation/rules/invalid/format/InvalidServerUrlRule.java @@ -17,6 +17,15 @@ package io.apicurio.datamodels.validation.rules.invalid.format; import io.apicurio.datamodels.models.Server; +import io.apicurio.datamodels.models.asyncapi.v20.AsyncApi20Server; +import io.apicurio.datamodels.models.asyncapi.v21.AsyncApi21Server; +import io.apicurio.datamodels.models.asyncapi.v22.AsyncApi22Server; +import io.apicurio.datamodels.models.asyncapi.v23.AsyncApi23Server; +import io.apicurio.datamodels.models.asyncapi.v24.AsyncApi24Server; +import io.apicurio.datamodels.models.asyncapi.v25.AsyncApi25Server; +import io.apicurio.datamodels.models.asyncapi.v26.AsyncApi26Server; +import io.apicurio.datamodels.models.openapi.OpenApiServer; +import io.apicurio.datamodels.util.ModelTypeUtil; import io.apicurio.datamodels.validation.ValidationRule; import io.apicurio.datamodels.validation.ValidationRuleMetaData; @@ -39,9 +48,40 @@ public InvalidServerUrlRule(ValidationRuleMetaData ruleInfo) { */ @Override public void visitServer(Server node) { - if (hasValue(node.getUrl())) { - this.reportIfInvalid(isValidUrlTemplate(node.getUrl()), node, "url", map()); + String url = getUrl(node); + if (hasValue(url)) { + this.reportIfInvalid(isValidUrlTemplate(url), node, "url", map()); } } + private String getUrl(Server node) { + if (ModelTypeUtil.isOpenApiModel(node)) { + return ((OpenApiServer) node).getUrl(); + } + if (ModelTypeUtil.isAsyncApi2Model(node)) { + if (node instanceof AsyncApi20Server) { + return ((AsyncApi20Server) node).getUrl(); + } + if (node instanceof AsyncApi21Server) { + return ((AsyncApi21Server) node).getUrl(); + } + if (node instanceof AsyncApi22Server) { + return ((AsyncApi22Server) node).getUrl(); + } + if (node instanceof AsyncApi23Server) { + return ((AsyncApi23Server) node).getUrl(); + } + if (node instanceof AsyncApi24Server) { + return ((AsyncApi24Server) node).getUrl(); + } + if (node instanceof AsyncApi25Server) { + return ((AsyncApi25Server) node).getUrl(); + } + if (node instanceof AsyncApi26Server) { + return ((AsyncApi26Server) node).getUrl(); + } + } + return null; + } + } diff --git a/src/main/java/io/apicurio/datamodels/validation/rules/invalid/value/OasInvalidOperationIdRule.java b/src/main/java/io/apicurio/datamodels/validation/rules/invalid/value/OasInvalidOperationIdRule.java index 2b747ce2..c03f27db 100755 --- a/src/main/java/io/apicurio/datamodels/validation/rules/invalid/value/OasInvalidOperationIdRule.java +++ b/src/main/java/io/apicurio/datamodels/validation/rules/invalid/value/OasInvalidOperationIdRule.java @@ -17,6 +17,7 @@ package io.apicurio.datamodels.validation.rules.invalid.value; import io.apicurio.datamodels.models.Operation; +import io.apicurio.datamodels.models.openapi.OpenApiOperation; import io.apicurio.datamodels.validation.ValidationRuleMetaData; /** @@ -47,8 +48,9 @@ protected static boolean isValidOperationId(String id) { */ @Override public void visitOperation(Operation node) { - if (hasValue(node.getOperationId())) { - this.reportIfInvalid(isValidOperationId(node.getOperationId()), node, "operationId", map()); + OpenApiOperation operation = (OpenApiOperation) node; + if (hasValue(operation.getOperationId())) { + this.reportIfInvalid(isValidOperationId(operation.getOperationId()), node, "operationId", map()); } } diff --git a/src/main/java/io/apicurio/datamodels/validation/rules/mutex/OasParameterSchemaContentMutualExclusivityRule.java b/src/main/java/io/apicurio/datamodels/validation/rules/mutex/OasParameterSchemaContentMutualExclusivityRule.java index 5df3995a..6c46fe1b 100755 --- a/src/main/java/io/apicurio/datamodels/validation/rules/mutex/OasParameterSchemaContentMutualExclusivityRule.java +++ b/src/main/java/io/apicurio/datamodels/validation/rules/mutex/OasParameterSchemaContentMutualExclusivityRule.java @@ -17,6 +17,7 @@ package io.apicurio.datamodels.validation.rules.mutex; import io.apicurio.datamodels.models.Parameter; +import io.apicurio.datamodels.models.openapi.OpenApiParameter; import io.apicurio.datamodels.models.openapi.v30.OpenApi30Parameter; import io.apicurio.datamodels.validation.ValidationRule; import io.apicurio.datamodels.validation.ValidationRuleMetaData; @@ -47,7 +48,8 @@ private boolean hasContent(OpenApi30Parameter contentParent) { */ @Override public void visitParameter(Parameter node) { - this.reportIf(hasValue(node.getSchema()) && hasContent((OpenApi30Parameter) node), node, "schema", map()); + OpenApiParameter parameter = (OpenApiParameter) node; + this.reportIf(hasValue(parameter.getSchema()) && hasContent((OpenApi30Parameter) node), node, "schema", map()); } } diff --git a/src/main/java/io/apicurio/datamodels/validation/rules/other/OasOperationIdUniquenessValidationRule.java b/src/main/java/io/apicurio/datamodels/validation/rules/other/OasOperationIdUniquenessValidationRule.java index 275fe72f..3b802ba2 100755 --- a/src/main/java/io/apicurio/datamodels/validation/rules/other/OasOperationIdUniquenessValidationRule.java +++ b/src/main/java/io/apicurio/datamodels/validation/rules/other/OasOperationIdUniquenessValidationRule.java @@ -22,6 +22,7 @@ import java.util.Map; import io.apicurio.datamodels.models.Operation; +import io.apicurio.datamodels.models.openapi.OpenApiOperation; import io.apicurio.datamodels.validation.ValidationRule; import io.apicurio.datamodels.validation.ValidationRuleMetaData; @@ -46,16 +47,17 @@ public OasOperationIdUniquenessValidationRule(ValidationRuleMetaData ruleInfo) { */ @Override public void visitOperation(Operation node) { - if (hasValue(node.getOperationId())) { - List dupes = this.indexedOperations.get(node.getOperationId()); + OpenApiOperation operation = (OpenApiOperation) node; + if (hasValue(operation.getOperationId())) { + List dupes = this.indexedOperations.get(operation.getOperationId()); if (hasValue(dupes)) { - this.reportIfInvalid(dupes.size() > 1, dupes.get(0), "operationId", map("operationId", node.getOperationId())); - this.report(node, "operationId", map("operationId", node.getOperationId())); + this.reportIfInvalid(dupes.size() > 1, dupes.get(0), "operationId", map("operationId", operation.getOperationId())); + this.report(node, "operationId", map("operationId", operation.getOperationId())); dupes.add(node); } else { dupes = new ArrayList<>(); dupes.add(node); - this.indexedOperations.put(node.getOperationId(), dupes); + this.indexedOperations.put(operation.getOperationId(), dupes); } } } diff --git a/src/main/java/io/apicurio/datamodels/validation/rules/other/TagUniquenessValidationRule.java b/src/main/java/io/apicurio/datamodels/validation/rules/other/TagUniquenessValidationRule.java index 9e053619..56bee886 100755 --- a/src/main/java/io/apicurio/datamodels/validation/rules/other/TagUniquenessValidationRule.java +++ b/src/main/java/io/apicurio/datamodels/validation/rules/other/TagUniquenessValidationRule.java @@ -16,13 +16,15 @@ package io.apicurio.datamodels.validation.rules.other; -import java.util.List; - -import io.apicurio.datamodels.models.Document; import io.apicurio.datamodels.models.Tag; +import io.apicurio.datamodels.models.openapi.OpenApiDocument; +import io.apicurio.datamodels.models.openapi.OpenApiTag; +import io.apicurio.datamodels.util.ModelTypeUtil; import io.apicurio.datamodels.validation.ValidationRule; import io.apicurio.datamodels.validation.ValidationRuleMetaData; +import java.util.List; + /** * Implements the Tag Name Uniqueness validation rule. * @author eric.wittmann@gmail.com @@ -42,14 +44,16 @@ public TagUniquenessValidationRule(ValidationRuleMetaData ruleInfo) { */ @Override public void visitTag(Tag node) { - List tags = ((Document) node.root()).getTags(); - int tcount = 0; - for (Tag tag : tags) { - if (equals(tag.getName(), node.getName())) { - tcount++; + if (ModelTypeUtil.isOpenApiModel(node)) { + List tags = ((OpenApiDocument) node.root()).getTags(); + int tcount = 0; + for (Tag tag : tags) { + if (equals(tag.getName(), node.getName())) { + tcount++; + } } + this.reportIf(tcount > 1, node, node.getName(), map("tagName", node.getName())); } - this.reportIf(tcount > 1, node, node.getName(), map("tagName", node.getName())); } } diff --git a/src/main/java/io/apicurio/datamodels/visitors/OperationFinder.java b/src/main/java/io/apicurio/datamodels/visitors/OperationFinder.java index ca2003fd..fc8bb0d8 100755 --- a/src/main/java/io/apicurio/datamodels/visitors/OperationFinder.java +++ b/src/main/java/io/apicurio/datamodels/visitors/OperationFinder.java @@ -17,6 +17,7 @@ package io.apicurio.datamodels.visitors; import io.apicurio.datamodels.models.Operation; +import io.apicurio.datamodels.models.openapi.OpenApiOperation; import io.apicurio.datamodels.models.visitors.CombinedVisitorAdapter; import io.apicurio.datamodels.util.NodeUtil; @@ -45,12 +46,9 @@ public OperationFinder(String operationId) { this.operationId = operationId; } - /** - * @see io.apicurio.datamodels.core.visitors.VisitorAdapter#visitOperation(io.apicurio.datamodels.core.models.common.Operation) - */ @Override public void visitOperation(Operation node) { - if (this.operationId == null || NodeUtil.equals(this.operationId, node.getOperationId())) { + if (this.operationId == null || NodeUtil.equals(this.operationId, ((OpenApiOperation) node).getOperationId())) { if (found == null) { this.found = node; } diff --git a/src/main/java/io/apicurio/datamodels/visitors/SecurityRequirementsFromParentVisitor.java b/src/main/java/io/apicurio/datamodels/visitors/SecurityRequirementsFromParentVisitor.java index 417a2fd2..c9a77dff 100755 --- a/src/main/java/io/apicurio/datamodels/visitors/SecurityRequirementsFromParentVisitor.java +++ b/src/main/java/io/apicurio/datamodels/visitors/SecurityRequirementsFromParentVisitor.java @@ -1,16 +1,13 @@ package io.apicurio.datamodels.visitors; -import java.util.List; - import io.apicurio.datamodels.models.Document; import io.apicurio.datamodels.models.Operation; import io.apicurio.datamodels.models.SecurityRequirement; -import io.apicurio.datamodels.models.Server; -import io.apicurio.datamodels.models.asyncapi.AsyncApiServer; import io.apicurio.datamodels.models.openapi.OpenApiDocument; import io.apicurio.datamodels.models.openapi.OpenApiOperation; import io.apicurio.datamodels.models.visitors.CombinedVisitorAdapter; -import io.apicurio.datamodels.util.ModelTypeUtil; + +import java.util.List; public class SecurityRequirementsFromParentVisitor extends CombinedVisitorAdapter { @@ -20,14 +17,6 @@ public List getSecurityRequirements() { return securityRequirements; } - @Override - public void visitServer(Server node) { - if (ModelTypeUtil.isAsyncApiModel(node)) { - AsyncApiServer server = (AsyncApiServer) node; - securityRequirements = server.getSecurity(); - } - } - @Override public void visitDocument(Document node) { OpenApiDocument doc = (OpenApiDocument) node; diff --git a/src/main/resources/specs/asyncapi.yaml b/src/main/resources/specs/asyncapi.yaml index 257d215f..17dd8a67 100755 --- a/src/main/resources/specs/asyncapi.yaml +++ b/src/main/resources/specs/asyncapi.yaml @@ -11,4 +11,4 @@ versions: - $ref: ./asyncapi/asyncapi-2.4.yaml - $ref: ./asyncapi/asyncapi-2.5.yaml - $ref: ./asyncapi/asyncapi-2.6.yaml - \ No newline at end of file + - $ref: ./asyncapi/asyncapi-3.0.yaml diff --git a/src/main/resources/specs/asyncapi/asyncapi-3.0.0.md b/src/main/resources/specs/asyncapi/asyncapi-3.0.0.md new file mode 100644 index 00000000..04a595d3 --- /dev/null +++ b/src/main/resources/specs/asyncapi/asyncapi-3.0.0.md @@ -0,0 +1,2760 @@ +# AsyncAPI Specification + +## Attribution + +Part of this content has been taken from the great work done by the folks at the [OpenAPI Initiative](https://openapis.org). + +### Version 3.0.0 + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). + +The AsyncAPI Specification is licensed under [The Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). + +## Introduction + +The AsyncAPI Specification is a project used to describe message-driven APIs in a machine-readable format. It’s protocol-agnostic, so you can use it for APIs that work over any protocol (e.g., AMQP, MQTT, WebSockets, Kafka, STOMP, HTTP, Mercure, etc). + +The AsyncAPI Specification defines a set of fields that can be used in an AsyncAPI document to describe an [application](#definitionsApplication)'s API. The document may reference other files for additional details or shared fields, but it is typically a single, primary document that encapsulates the API description. + +The AsyncAPI document SHOULD describe the operations an [application](#definitionsApplication) performs. For instance, consider the following AsyncAPI definition snippet: + +```yaml +channels: + userSignedUp: + # ...(redacted for brevity) +operations: + onUserSignedUp: + action: receive + channel: + $ref: '#/channels/userSignedUp' +``` + +It means that the [application](#definitionsApplication) will receive messages from the `userSignedUp` [channel](#definitionsChannel). + +**The AsyncAPI specification does not assume any kind of software topology, architecture or pattern.** Therefore, a server MAY be a message broker, a web server or any other kind of computer program capable of sending and/or receiving data. However, AsyncAPI offers a mechanism called "bindings" that aims to help with more specific information about the protocol. + +It's NOT RECOMMENDED to derive a [receiver](#definitionsReceiver) AsyncAPI document from a [sender](#definitionsSender) one or vice versa. There are no guarantees that the channel used by an application to receive messages will be the same channel where another application is sending them. Also, certain fields in the document like `summary`, `description`, and the id of the operation might stop making sense. For instance, given the following receiver snippet: + +```yaml +operations: + onUserSignedUp: + summary: On user signed up. + description: Event received when a user signed up on the product. + action: receive + channel: + $ref: '#/channels/userSignedUp' +``` + +We can't automatically assume that an _opposite_ application exists by simply replacing `receive` with `send`: + +```yaml +operations: + onUserSignedUp: # <-- This doesn't make sense now. Should be something like sendUserSignedUp. + summary: On user signed up. # <-- This doesn't make sense now. Should say something like "Sends a user signed up event". + description: Event received when a user signed up on the product. # <-- This doesn't make sense now. Should speak about sending an event, not receiving it. + action: send + channel: + $ref: '#/channels/userSignedUp' +``` + +Aside from the issues mentioned above, there may also be infrastructure configuration that is not represented here. For instance, a system may use a read-only channel for receiving messages, a different one for sending them, and an intermediary process that will forward messages from one channel to the other. + +## Table of Contents + + +- [Definitions](#definitions) + - [Server](#definitionsServer) + - [Application](#definitionsApplication) + - [Sender](#definitionsSender) + - [Receiver](#definitionsReceiver) + - [Message](#definitionsMessage) + - [Channel](#definitionsChannel) + - [Protocol](#definitionsProtocol) +- [Specification](#specification) + - [Format](#format) + - [File Structure](#file-structure) + - [Absolute URLs](#absolute-urls) + - [Schema](#schema) + - [AsyncAPI Object](#A2SObject) + - [AsyncAPI Version String](#A2SVersionString) + - [Identifier](#A2SIdString) + - [Info Object](#infoObject) + - [Contact Object](#contactObject) + - [License Object](#licenseObject) + - [Servers Object](#serversObject) + - [Server Object](#serverObject) + - [Server Variable Object](#serverVariableObject) + - [Default Content Type](#defaultContentTypeString) + - [Channels Object](#channelsObject) + - [Channel Object](#channelObject) + - [Operations Object](#operationsObject) + - [Operation Object](#operationObject) + - [Operation Trait Object](#operationTraitObject) + - [Operation Reply Object](#operationReplyObject) + - [Operation Reply Address Object](#operationReplyAddressObject) + - [Message Object](#messageObject) + - [Message Trait Object](#messageTraitObject) + - [Message Example Object](#messageExampleObject) + - [Tags Object](#tagsObject) + - [Tag Object](#tag-object) + - [External Documentation Object](#externalDocumentationObject) + - [Components Object](#componentsObject) + - [Reference Object](#referenceObject) + - [Multi Format Schema Object](#multiFormatSchemaObject) + - [Schema Object](#schemaObject) + - [Security Scheme Object](#securitySchemeObject) + - [OAuth Flows Object](#oauth-flows-object) + - [OAuth Flow Object](#oauth-flow-object) + - [Server Bindings Object](#serverBindingsObject) + - [Parameters Object](#parametersObject) + - [Parameter Object](#parameterObject) + - [Channel Bindings Object](#channelBindingsObject) + - [Operation Bindings Object](#operationBindingsObject) + - [Message Bindings Object](#messageBindingsObject) + - [Correlation ID Object](#correlationIdObject) + - [Specification Extensions](#specificationExtensions) + + + +## Definitions + +### Server + +A server MAY be a message broker that is capable of sending and/or receiving between a [sender](#definitionsSender) and [receiver](#definitionsReceiver). A server MAY be a service with WebSocket API that enables message-driven communication between browser-to-server or server-to-server. + +### Application + +An application is any kind of computer program or a group of them. It MUST be a [sender](#definitionsSender), a [receiver](#definitionsReceiver), or both. An application MAY be a microservice, IoT device (sensor), mainframe process, message broker, etc. An application MAY be written in any number of different programming languages as long as they support the selected [protocol](#definitionsProtocol). An application MUST also use a protocol supported by the [server](#definitionsServer) in order to connect and exchange [messages](#definitionsMessage). + +### Sender + +A sender is a type of application, that is sending [messages](#definitionsMessage) to [channels](#definitionsChannel). A sender MAY send to multiple channels depending on the [server](#definitionsServer), protocol, and use-case pattern. + +### Receiver + +A receiver is a type of application that is receiving [messages](#definitionsMessage) from [channels](#definitionsChannel). A receiver MAY receive from multiple channels depending on the [server](#definitionsServer), protocol, and the use-case pattern. A receiver MAY forward a received message further without changing it. A receiver MAY act as a consumer and react to the message. A receiver MAY act as a processor that, for example, aggregates multiple messages in one and forwards them. + +### Message + +A message is the mechanism by which information is exchanged via a channel between [servers](#definitionsServer) and applications. A message MAY contain a payload and MAY also contain headers. The headers MAY be subdivided into [protocol](#definitionsProtocol)-defined headers and header properties defined by the application which can act as supporting metadata. The payload contains the data, defined by the application, which MUST be serialized into a format (JSON, XML, Avro, binary, etc.). Since a message is a generic mechanism, it can support multiple interaction patterns such as event, command, request, or response. + +### Channel + +A channel is an addressable component, made available by the [server](#definitionsServer), for the organization of [messages](#definitionsMessage). [Sender](#definitionsSender) applications send messages to channels and [receiver](#definitionsReceiver) applications receive messages from channels. [Servers](#definitionsServer) MAY support many channel instances, allowing messages with different content to be addressed to different channels. Depending on the [server](#definitionsServer) implementation, the channel MAY be included in the message via protocol-defined headers. + +### Protocol + +A protocol is the mechanism (wireline protocol or API) by which [messages](#definitionsMessage) are exchanged between the application and the [channel](#definitionsChannel). Example protocols include, but are not limited to, AMQP, HTTP, JMS, Kafka, Anypoint MQ, MQTT, Solace, STOMP, Mercure, WebSocket, Google Pub/Sub, Pulsar. + +### Bindings + +A "binding" (or "protocol binding") is a mechanism to define protocol-specific information. Therefore, a protocol binding MUST define protocol-specific information only. + +## Specification + +### Format + +The files describing the message-driven API in accordance with the AsyncAPI Specification are represented as JSON objects and conform to the JSON standards. +YAML, being a superset of JSON, can be used as well to represent a A2S (AsyncAPI Specification) file. + +For example, if a field is said to have an array value, the JSON array representation will be used: + +```yaml +{ + "field" : [...] +} +``` + +While the API is described using JSON it does not impose a JSON input/output to the API itself. + +All field names in the specification are **case sensitive**. + +The schema exposes two types of fields. +Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. +Patterned fields can have multiple occurrences as long as each has a unique name. + +In order to preserve the ability to round-trip between YAML and JSON formats, YAML version [1.2](https://www.yaml.org/spec/1.2/spec.html) is recommended along with some additional constraints: + +- Tags MUST be limited to those allowed by the [JSON Schema ruleset](https://www.yaml.org/spec/1.2/spec.html#id2803231) +- Keys used in YAML maps MUST be limited to a scalar string, as defined by the YAML Failsafe schema ruleset + +### File Structure + +An AsyncAPI document MAY be made up of a single document or be divided into multiple, +connected parts at the discretion of the author. In the latter case, [Reference Objects](#referenceObject) are used. + +It is important to note that everything that is defined in an AsyncAPI document MUST be used by the implemented [Application](#definitionsApplication), with the exception of the [Components Object](#componentsObject). Everything that is defined inside the Components Object represents a resource that MAY or MAY NOT be used by the implemented [Application](#definitionsApplication). + +By convention, the AsyncAPI Specification (A2S) file is named `asyncapi.json` or `asyncapi.yaml`. + +### Absolute URLs + +Unless specified otherwise, all properties that are absolute URLs are defined by [RFC3986, section 4.3](https://datatracker.ietf.org/doc/html/rfc3986#section-4.3). + +### Schema + +#### AsyncAPI Object + +This is the root document object for the API specification. +It combines resource listing and API declaration together into one document. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +asyncapi | [AsyncAPI Version String](#A2SVersionString) | **REQUIRED.** Specifies the AsyncAPI Specification version being used. It can be used by tooling Specifications and clients to interpret the version. The structure shall be `major`.`minor`.`patch`, where `patch` versions _must_ be compatible with the existing `major`.`minor` tooling. Typically patch versions will be introduced to address errors in the documentation, and tooling should typically be compatible with the corresponding `major`.`minor` (1.0.*). Patch versions will correspond to patches of this document. +id | [Identifier](#A2SIdString) | Identifier of the [application](#definitionsApplication) the AsyncAPI document is defining. +info | [Info Object](#infoObject) | **REQUIRED.** Provides metadata about the API. The metadata can be used by the clients if needed. +servers | [Servers Object](#serversObject) | Provides connection details of servers. +defaultContentType | [Default Content Type](#defaultContentTypeString) | Default content type to use when encoding/decoding a message's payload. +channels | [Channels Object](#channelsObject) | The channels used by this [application](#definitionsApplication). +operations | [Operations Object](#operationsObject) | The operations this [application](#definitionsApplication) MUST implement. +components | [Components Object](#componentsObject) | An element to hold various reusable objects for the specification. Everything that is defined inside this object represents a resource that MAY or MAY NOT be used in the rest of the document and MAY or MAY NOT be used by the implemented [Application](#definitionsApplication). + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### AsyncAPI Version String + +The version string signifies the version of the AsyncAPI Specification that the document complies to. +The format for this string _must_ be `major`.`minor`.`patch`. The `patch` _may_ be suffixed by a hyphen and extra alphanumeric characters. + +A `major`.`minor` shall be used to designate the AsyncAPI Specification version, and will be considered compatible with the AsyncAPI Specification specified by that `major`.`minor` version. +The patch version will not be considered by tooling, making no distinction between `1.0.0` and `1.0.1`. + +In subsequent versions of the AsyncAPI Specification, care will be given such that increments of the `minor` version should not interfere with operations of tooling developed to a lower minor version. Thus a hypothetical `1.1.0` specification should be usable with tooling designed for `1.0.0`. + +#### Identifier + +This field represents a unique universal identifier of the [application](#definitionsApplication) the AsyncAPI document is defining. It must conform to the URI format, according to [RFC3986](https://tools.ietf.org/html/rfc3986). + +It is RECOMMENDED to use a [URN](https://tools.ietf.org/html/rfc8141) to globally and uniquely identify the application during long periods of time, even after it becomes unavailable or ceases to exist. + +##### Examples + +```json +{ + "id": "urn:example:com:smartylighting:streetlights:server" +} +``` + +```yaml +id: 'urn:example:com:smartylighting:streetlights:server' +``` + +```json +{ + "id": "https://github.com/smartylighting/streetlights-server" +} +``` + +```yaml +id: 'https://github.com/smartylighting/streetlights-server' +``` + +#### Info Object + +The object provides metadata about the API. +The metadata can be used by the clients if needed. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +title | `string` | **REQUIRED.** The title of the application. +version | `string` | **REQUIRED** Provides the version of the application API (not to be confused with the specification version). +description | `string` | A short description of the application. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +termsOfService | `string` | A URL to the Terms of Service for the API. This MUST be in the form of an absolute URL. +contact | [Contact Object](#contactObject) | The contact information for the exposed API. +license | [License Object](#licenseObject) | The license information for the exposed API. +tags | [Tags Object](#tagsObject) | A list of tags for application API documentation control. Tags can be used for logical grouping of applications. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation of the exposed API. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Info Object Example + + +```json +{ + "title": "AsyncAPI Sample App", + "version": "1.0.1", + "description": "This is a sample app.", + "termsOfService": "https://asyncapi.org/terms/", + "contact": { + "name": "API Support", + "url": "https://www.asyncapi.org/support", + "email": "support@asyncapi.org" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "externalDocs": { + "description": "Find more info here", + "url": "https://www.asyncapi.org" + }, + "tags": [ + { + "name": "e-commerce" + } + ] +} +``` + + +```yaml +title: AsyncAPI Sample App +version: 1.0.1 +description: This is a sample app. +termsOfService: https://asyncapi.org/terms/ +contact: + name: API Support + url: https://www.asyncapi.org/support + email: support@asyncapi.org +license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html +externalDocs: + description: Find more info here + url: https://www.asyncapi.org +tags: + - name: e-commerce +``` + +#### Contact Object + +Contact information for the exposed API. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +name | `string` | The identifying name of the contact person/organization. +url | `string` | The URL pointing to the contact information. This MUST be in the form of an absolute URL. +email | `string` | The email address of the contact person/organization. MUST be in the format of an email address. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Contact Object Example + + +```json +{ + "name": "API Support", + "url": "https://www.example.com/support", + "email": "support@example.com" +} +``` + + +```yaml +name: API Support +url: https://www.example.com/support +email: support@example.com +``` + +#### License Object + +License information for the exposed API. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +name | `string` | **REQUIRED.** The license name used for the API. +url | `string` | A URL to the license used for the API. This MUST be in the form of an absolute URL. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### License Object Example + + +```json +{ + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" +} +``` + + +```yaml +name: Apache 2.0 +url: https://www.apache.org/licenses/LICENSE-2.0.html +``` + +#### Servers Object + +The Servers Object is a map of [Server Objects](#serverObject). + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +`^[A-Za-z0-9_\-]+$` | [Server Object](#serverObject) \| [Reference Object](#referenceObject) | The definition of a server this application MAY connect to. + +##### Servers Object Example + + +```json +{ + "development": { + "host": "localhost:5672", + "description": "Development AMQP broker.", + "protocol": "amqp", + "protocolVersion": "0-9-1", + "tags": [ + { + "name": "env:development", + "description": "This environment is meant for developers to run their own tests." + } + ] + }, + "staging": { + "host": "rabbitmq-staging.in.mycompany.com:5672", + "description": "RabbitMQ broker for the staging environment.", + "protocol": "amqp", + "protocolVersion": "0-9-1", + "tags": [ + { + "name": "env:staging", + "description": "This environment is a replica of the production environment." + } + ] + }, + "production": { + "host": "rabbitmq.in.mycompany.com:5672", + "description": "RabbitMQ broker for the production environment.", + "protocol": "amqp", + "protocolVersion": "0-9-1", + "tags": [ + { + "name": "env:production", + "description": "This environment is the live environment available for final users." + } + ] + } +} +``` + + +```yaml +development: + host: localhost:5672 + description: Development AMQP broker. + protocol: amqp + protocolVersion: 0-9-1 + tags: + - name: 'env:development' + description: 'This environment is meant for developers to run their own tests.' +staging: + host: rabbitmq-staging.in.mycompany.com:5672 + description: RabbitMQ broker for the staging environment. + protocol: amqp + protocolVersion: 0-9-1 + tags: + - name: 'env:staging' + description: 'This environment is a replica of the production environment.' +production: + host: rabbitmq.in.mycompany.com:5672 + description: RabbitMQ broker for the production environment. + protocol: amqp + protocolVersion: 0-9-1 + tags: + - name: 'env:production' + description: 'This environment is the live environment available for final users.' +``` + +#### Server Object + +An object representing a message broker, a server or any other kind of computer program capable of sending and/or receiving data. This object is used to capture details such as URIs, protocols and security configuration. Variable substitution can be used so that some details, for example usernames and passwords, can be injected by code generation tools. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +host | `string` | **REQUIRED**. The server host name. It MAY include the port. This field supports [Server Variables](#serverObjectVariables). Variable substitutions will be made when a variable is named in `{`braces`}`. +protocol | `string` | **REQUIRED**. The protocol this server supports for connection. +protocolVersion | `string` | The version of the protocol used for connection. For instance: AMQP `0.9.1`, HTTP `2.0`, Kafka `1.0.0`, etc. +pathname | `string` | The path to a resource in the host. This field supports [Server Variables](#serverObjectVariables). Variable substitutions will be made when a variable is named in `{`braces`}`. +description | `string` | An optional string describing the server. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. +title | `string` | A human-friendly title for the server. +summary | `string` | A short summary of the server. +variables | Map[`string`, [Server Variable Object](#serverVariableObject) \| [Reference Object](#referenceObject)]] | A map between a variable name and its value. The value is used for substitution in the server's `host` and `pathname` template. +security | [[Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | A declaration of which security schemes can be used with this server. The list of values includes alternative [security scheme objects](#securitySchemeObject) that can be used. Only one of the security scheme objects need to be satisfied to authorize a connection or operation. +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping and categorization of servers. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this server. +bindings | [Server Bindings Object](#serverBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the server. + +##### Server Object Example + +A single server would be described as: + + +```json +{ + "host": "kafka.in.mycompany.com:9092", + "description": "Production Kafka broker.", + "protocol": "kafka", + "protocolVersion": "3.2" +} +``` + + +```yaml +host: kafka.in.mycompany.com:9092 +description: Production Kafka broker. +protocol: kafka +protocolVersion: '3.2' +``` + +An example of a server that has a `pathname`: + + +```json +{ + "host": "rabbitmq.in.mycompany.com:5672", + "pathname": "/production", + "protocol": "amqp", + "description": "Production RabbitMQ broker (uses the `production` vhost)." +} +``` + + +```yaml +host: rabbitmq.in.mycompany.com:5672 +pathname: /production +protocol: amqp +description: Production RabbitMQ broker (uses the `production` vhost). +``` + +#### Server Variable Object + +An object representing a Server Variable for server URL template substitution. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. +default | `string` | The default value to use for substitution, and to send, if an alternate value is _not_ supplied. +description | `string` | An optional description for the server variable. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. +examples | [`string`] | An array of examples of the server variable. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Server Variable Object Example + + +```json +{ + "host": "rabbitmq.in.mycompany.com:5672", + "pathname": "/{env}", + "protocol": "amqp", + "description": "RabbitMQ broker. Use the `env` variable to point to either `production` or `staging`.", + "variables": { + "env": { + "description": "Environment to connect to. It can be either `production` or `staging`.", + "enum": [ + "production", + "staging" + ] + } + } +} +``` + + +```yaml +host: 'rabbitmq.in.mycompany.com:5672' +pathname: '/{env}' +protocol: amqp +description: RabbitMQ broker. Use the `env` variable to point to either `production` or `staging`. +variables: + env: + description: Environment to connect to. It can be either `production` or `staging`. + enum: + - production + - staging +``` + +#### Default Content Type + +A string representing the default content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. `application/json`). This value MUST be used by schema parsers when the [contentType](#messageObjectContentType) property is omitted. + +In case a message can't be encoded/decoded using this value, schema parsers MUST use their default content type. + +##### Default Content Type Example + + +```json +{ + "defaultContentType": "application/json" +} +``` + + +```yaml +defaultContentType: application/json +``` + +#### Channels Object + +An object containing all the [Channel Object](#channelObject) definitions the [Application](#definitionsApplication) MUST use during runtime. + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +{channelId} | [Channel Object](#channelObject) \| [Reference Object](#referenceObject) | An identifier for the described channel. The `channelId` value is **case-sensitive**. Tools and libraries MAY use the `channelId` to uniquely identify a channel, therefore, it is RECOMMENDED to follow common programming naming conventions. + +##### Channels Object Example + + +```json +{ + "userSignedUp": { + "address": "user.signedup", + "messages": { + "userSignedUp": { + "$ref": "#/components/messages/userSignedUp" + } + } + } +} +``` + + +```yaml +userSignedUp: + address: 'user.signedup' + messages: + userSignedUp: + $ref: '#/components/messages/userSignedUp' +``` + +#### Channel Object + +Describes a shared communication channel. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +address | `string` \| `null` | An optional string representation of this channel's address. The address is typically the "topic name", "routing key", "event type", or "path". When `null` or absent, it MUST be interpreted as unknown. This is useful when the address is generated dynamically at runtime or can't be known upfront. It MAY contain [Channel Address Expressions](#channelAddressExpressions). Query parameters and fragments SHALL NOT be used, instead use [bindings](#channelBindingsObject) to define them. +messages | [Messages Object](#messagesObject) | A map of the messages that will be sent to this channel by any application at any time. **Every message sent to this channel MUST be valid against one, and only one, of the [message objects](#messageObject) defined in this map.** +title | `string` | A human-friendly title for the channel. +summary | `string` | A short summary of the channel. +description | `string` | An optional description of this channel. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +servers | [[Reference Object](#referenceObject)] | An array of `$ref` pointers to the definition of the servers in which this channel is available. If the channel is located in the [root Channels Object](#channelsObject), it MUST point to a subset of server definitions located in the [root Servers Object](#serversObject), and MUST NOT point to a subset of server definitions located in the [Components Object](#componentsObject) or anywhere else. If the channel is located in the [Components Object](#componentsObject), it MAY point to a [Server Objects](#serverObject) in any location. If `servers` is absent or empty, this channel MUST be available on all the servers defined in the [Servers Object](#serversObject). Please note the `servers` property value MUST be an array of [Reference Objects](#referenceObject) and, therefore, MUST NOT contain an array of [Server Objects](#serverObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +parameters | [Parameters Object](#parametersObject) | A map of the parameters included in the channel address. It MUST be present only when the address contains [Channel Address Expressions](#channelAddressExpressions). +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping of channels. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this channel. +bindings | [Channel Bindings Object](#channelBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the channel. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Channel Object Example + + +```json +{ + "address": "users.{userId}", + "title": "Users channel", + "description": "This channel is used to exchange messages about user events.", + "messages": { + "userSignedUp": { + "$ref": "#/components/messages/userSignedUp" + }, + "userCompletedOrder": { + "$ref": "#/components/messages/userCompletedOrder" + } + }, + "parameters": { + "userId": { + "$ref": "#/components/parameters/userId" + } + }, + "servers": [ + { "$ref": "#/servers/rabbitmqInProd" }, + { "$ref": "#/servers/rabbitmqInStaging" } + ], + "bindings": { + "amqp": { + "is": "queue", + "queue": { + "exclusive": true + } + } + }, + "tags": [{ + "name": "user", + "description": "User-related messages" + }], + "externalDocs": { + "description": "Find more info here", + "url": "https://example.com" + } +} +``` + + +```yaml +address: 'users.{userId}' +title: Users channel +description: This channel is used to exchange messages about user events. +messages: + userSignedUp: + $ref: '#/components/messages/userSignedUp' + userCompletedOrder: + $ref: '#/components/messages/userCompletedOrder' +parameters: + userId: + $ref: '#/components/parameters/userId' +servers: + - $ref: '#/servers/rabbitmqInProd' + - $ref: '#/servers/rabbitmqInStaging' +bindings: + amqp: + is: queue + queue: + exclusive: true +tags: + - name: user + description: User-related messages +externalDocs: + description: 'Find more info here' + url: 'https://example.com' +``` + +#### Channel Address Expressions + +Channel addresses MAY contain expressions that can be used to define dynamic values. + +Expressions MUST be composed by a name enclosed in curly braces (`{` and `}`). E.g., `{userId}`. + +#### Messages Object + +Describes a map of messages included in a channel. + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +`{messageId}` | [Message Object](#messageObject) \| [Reference Object](#referenceObject) | The key represents the message identifier. The `messageId` value is **case-sensitive**. Tools and libraries MAY use the `messageId` value to uniquely identify a message, therefore, it is RECOMMENDED to follow common programming naming conventions. + +##### Messages Object Example + + +```json +{ + "userSignedUp": { + "$ref": "#/components/messages/userSignedUp" + }, + "userCompletedOrder": { + "$ref": "#/components/messages/userCompletedOrder" + } +} +``` + + +```yaml +userSignedUp: + $ref: '#/components/messages/userSignedUp' +userCompletedOrder: + $ref: '#/components/messages/userCompletedOrder' +``` + +#### Operations Object + +Holds a dictionary with all the [operations](#operationObject) this application MUST implement. + +> If you're looking for a place to define operations that MAY or MAY NOT be implemented by the application, consider defining them in [`components/operations`](#componentsOperations). + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +{operationId} | [Operation Object](#operationObject) \| [Reference Object](#referenceObject) | The operation this application MUST implement. The field name (`operationId`) MUST be a string used to identify the operation in the document where it is defined, and its value is **case-sensitive**. Tools and libraries MAY use the `operationId` to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. + +##### Operations Object Example + + +```json +{ + "onUserSignUp": { + "title": "User sign up", + "summary": "Action to sign a user up.", + "description": "A longer description", + "channel": { + "$ref": "#/channels/userSignup" + }, + "action": "send", + "tags": [ + { "name": "user" }, + { "name": "signup" }, + { "name": "register" } + ], + "bindings": { + "amqp": { + "ack": false + } + }, + "traits": [ + { "$ref": "#/components/operationTraits/kafka" } + ] + } +} +``` + + +```yaml +onUserSignUp: + title: User sign up + summary: Action to sign a user up. + description: A longer description + channel: + $ref: '#/channels/userSignup' + action: send + tags: + - name: user + - name: signup + - name: register + bindings: + amqp: + ack: false + traits: + - $ref: '#/components/operationTraits/kafka' +``` + +#### Operation Object + +Describes a specific operation. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +action | `"send"` | `"receive"` | **Required**. Use `send` when it's expected that the application will send a message to the given [`channel`](#operationObjectChannel), and `receive` when the application should expect receiving messages from the given [`channel`](#operationObjectChannel). +channel | [Reference Object](#referenceObject) | **Required**. A `$ref` pointer to the definition of the channel in which this operation is performed. If the operation is located in the [root Operations Object](#operationsObject), it MUST point to a channel definition located in the [root Channels Object](#channelsObject), and MUST NOT point to a channel definition located in the [Components Object](#componentsObject) or anywhere else. If the operation is located in the [Components Object](#componentsObject), it MAY point to a [Channel Object](#channelObject) in any location. Please note the `channel` property value MUST be a [Reference Object](#referenceObject) and, therefore, MUST NOT contain a [Channel Object](#channelObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +title | `string` | A human-friendly title for the operation. +summary | `string` | A short summary of what the operation is about. +description | `string` | A verbose explanation of the operation. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. +security | [[Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)]| A declaration of which security schemes are associated with this operation. Only one of the [security scheme objects](#securitySchemeObject) MUST be satisfied to authorize an operation. In cases where [Server Security](#serverObjectSecurity) also applies, it MUST also be satisfied. +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping and categorization of operations. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this operation. +bindings | [Operation Bindings Object](#operationBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. +traits | [[Operation Trait Object](#operationTraitObject) | [Reference Object](#referenceObject) ] | A list of traits to apply to the operation object. Traits MUST be merged using [traits merge mechanism](#traits-merge-mechanism). The resulting object MUST be a valid [Operation Object](#operationObject). +messages | [[Reference Object](#referenceObject)] | A list of `$ref` pointers pointing to the supported [Message Objects](#messageObject) that can be processed by this operation. It MUST contain a subset of the messages defined in the [channel referenced in this operation](#operationObjectChannel), and MUST NOT point to a subset of message definitions located in the [Messages Object](#componentsMessages) in the [Components Object](#componentsObject) or anywhere else. **Every message processed by this operation MUST be valid against one, and only one, of the [message objects](#messageObject) referenced in this list.** Please note the `messages` property value MUST be a list of [Reference Objects](#referenceObject) and, therefore, MUST NOT contain [Message Objects](#messageObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +reply | [Operation Reply Object](#operationReplyObject) | [Reference Object](#referenceObject) | The definition of the reply in a request-reply operation. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Operation Object Example + + +```json +{ + "title": "User sign up", + "summary": "Action to sign a user up.", + "description": "A longer description", + "channel": { + "$ref": "#/channels/userSignup" + }, + "action": "send", + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "subscribe:auth_revocations": "Scope required for authorization revocation topic" + } + } + }, + "scopes": [ + "subscribe:auth_revocations" + ], + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "tags": [ + { "name": "user" }, + { "name": "signup" }, + { "name": "register" } + ], + "bindings": { + "amqp": { + "ack": false + } + }, + "traits": [ + { "$ref": "#/components/operationTraits/kafka" } + ], + "messages": [ + { "$ref": "#/channels/userSignup/messages/userSignedUp" } + ], + "reply": { + "address": { + "location": "$message.header#/replyTo" + }, + "channel": { + "$ref": "#/channels/userSignupReply" + }, + "messages": [ + { "$ref": "#/channels/userSignupReply/messages/userSignedUpReply" } + ] + } +} +``` + + +```yaml +title: User sign up +summary: Action to sign a user up. +description: A longer description +channel: + $ref: '#/channels/userSignup' +action: send +security: + - type: oauth2 + description: The oauth security descriptions + flows: + clientCredentials: + tokenUrl: 'https://example.com/api/oauth/dialog' + availableScopes: + 'subscribe:auth_revocations': Scope required for authorization revocation topic + scopes: + - 'subscribe:auth_revocations' + petstore_auth: + - 'write:pets' + - 'read:pets' +tags: + - name: user + - name: signup + - name: register +bindings: + amqp: + ack: false +traits: + - $ref: '#/components/operationTraits/kafka' +messages: + - $ref: '#/channels/userSignup/messages/userSignedUp' +reply: + address: + location: '$message.header#/replyTo' + channel: + $ref: '#/channels/userSignupReply' + messages: + - $ref: '#/channels/userSignupReply/messages/userSignedUpReply' +``` + +#### Operation Trait Object + +Describes a trait that MAY be applied to an [Operation Object](#operationObject). This object MAY contain any property from the [Operation Object](#operationObject), except the `action`, `channel`, `messages` and `traits` ones. + +If you're looking to apply traits to a message, see the [Message Trait Object](#messageTraitObject). + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +title | `string` | A human-friendly title for the operation. +summary | `string` | A short summary of what the operation is about. +description | `string` | A verbose explanation of the operation. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +security | [[Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)]| A declaration of which security schemes are associated with this operation. Only one of the [security scheme objects](#securitySchemeObject) MUST be satisfied to authorize an operation. In cases where [Server Security](#serverObjectSecurity) also applies, it MUST also be satisfied. +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping and categorization of operations. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this operation. +bindings | [Operation Bindings Object](#operationBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Operation Trait Object Example + + +```json +{ + "bindings": { + "amqp": { + "ack": false + } + } +} +``` + + +```yaml +bindings: + amqp: + ack: false +``` + +#### Operation Reply Object + +Describes the reply part that MAY be applied to an Operation Object. If an operation implements the request/reply pattern, the reply object represents the response message. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +address | [Operation Reply Address Object](#operationReplyAddressObject) | [Reference Object](#referenceObject) | Definition of the address that implementations MUST use for the reply. +channel | [Reference Object](#referenceObject) | A `$ref` pointer to the definition of the channel in which this operation is performed. When [address](#operationReplyAddressObject) is specified, the [`address` property](#channelObjectAddress) of the channel referenced by this property MUST be either `null` or not defined. If the operation reply is located inside a [root Operation Object](#operationObject), it MUST point to a channel definition located in the [root Channels Object](#channelsObject), and MUST NOT point to a channel definition located in the [Components Object](#componentsObject) or anywhere else. If the operation reply is located inside an [Operation Object] in the [Components Object](#componentsObject) or in the [Replies Object](#componentsReplies) in the [Components Object](#componentsObject), it MAY point to a [Channel Object](#channelObject) in any location. Please note the `channel` property value MUST be a [Reference Object](#referenceObject) and, therefore, MUST NOT contain a [Channel Object](#channelObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +messages | [[Reference Object](#referenceObject)] | A list of `$ref` pointers pointing to the supported [Message Objects](#messageObject) that can be processed by this operation as reply. It MUST contain a subset of the messages defined in the [channel referenced in this operation reply](#operationObjectChannel), and MUST NOT point to a subset of message definitions located in the [Components Object](#componentsObject) or anywhere else. **Every message processed by this operation MUST be valid against one, and only one, of the [message objects](#messageObject) referenced in this list.** Please note the `messages` property value MUST be a list of [Reference Objects](#referenceObject) and, therefore, MUST NOT contain [Message Objects](#messageObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Operation Reply Address Object + +An object that specifies where an operation has to send the reply. + +For specifying and computing the location of a reply address, a [runtime expression](#runtimeExpression) is used. + +##### Fixed Fields + +Field Name | Type | Description +---|:---|--- +description | `string` | An optional description of the address. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +location | `string` | **REQUIRED.** A [runtime expression](#runtimeExpression) that specifies the location of the reply address. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Examples + + +```json +{ + "description": "Consumer inbox", + "location": "$message.header#/replyTo" +} +``` + + +```yaml +description: Consumer Inbox +location: $message.header#/replyTo +``` + +#### Parameters Object + +Describes a map of parameters included in a channel address. + +This map MUST contain all the parameters used in the parent channel address. + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +`^[A-Za-z0-9_\-]+$` | [Parameter Object](#parameterObject) | [Reference Object](#referenceObject) | The key represents the name of the parameter. It MUST match the parameter name used in the parent channel address. + +##### Parameters Object Example + + +```json +{ + "address": "user/{userId}/signedup", + "parameters": { + "userId": { + "description": "Id of the user." + } + } +} +``` + + +```yaml +address: user/{userId}/signedup +parameters: + userId: + description: Id of the user. +``` + +#### Parameter Object + +Describes a parameter included in a channel address. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. +default | `string` | The default value to use for substitution, and to send, if an alternate value is _not_ supplied. +description | `string` | An optional description for the parameter. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. +examples | [`string`] | An array of examples of the parameter value. +location | `string` | A [runtime expression](#runtimeExpression) that specifies the location of the parameter value. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Parameter Object Example + + +```json +{ + "address": "user/{userId}/signedup", + "parameters": { + "userId": { + "description": "Id of the user.", + "location": "$message.payload#/user/id" + } + } +} +``` + + +```yaml +address: user/{userId}/signedup +parameters: + userId: + description: Id of the user. + location: $message.payload#/user/id +``` + +#### Server Bindings Object + +Map describing protocol-specific definitions for a server. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +`http` | [HTTP Server Binding](https://github.com/asyncapi/bindings/blob/master/http#server) | Protocol-specific information for an HTTP server. +`ws` | [WebSockets Server Binding](https://github.com/asyncapi/bindings/blob/master/websockets#server) | Protocol-specific information for a WebSockets server. +`kafka` | [Kafka Server Binding](https://github.com/asyncapi/bindings/blob/master/kafka#server) | Protocol-specific information for a Kafka server. +`anypointmq` | [Anypoint MQ Server Binding](https://github.com/asyncapi/bindings/blob/master/anypointmq#server) | Protocol-specific information for an Anypoint MQ server. +`amqp` | [AMQP Server Binding](https://github.com/asyncapi/bindings/blob/master/amqp#server) | Protocol-specific information for an AMQP 0-9-1 server. +`amqp1` | [AMQP 1.0 Server Binding](https://github.com/asyncapi/bindings/blob/master/amqp1#server) | Protocol-specific information for an AMQP 1.0 server. +`mqtt` | [MQTT Server Binding](https://github.com/asyncapi/bindings/blob/master/mqtt#server) | Protocol-specific information for an MQTT server. +`mqtt5` | [MQTT 5 Server Binding](https://github.com/asyncapi/bindings/blob/master/mqtt5#server) | Protocol-specific information for an MQTT 5 server. +`nats` | [NATS Server Binding](https://github.com/asyncapi/bindings/blob/master/nats#server) | Protocol-specific information for a NATS server. +`jms` | [JMS Server Binding](https://github.com/asyncapi/bindings/blob/master/jms#server) | Protocol-specific information for a JMS server. +`sns` | [SNS Server Binding](https://github.com/asyncapi/bindings/blob/master/sns#server) | Protocol-specific information for an SNS server. +`solace` | [Solace Server Binding](https://github.com/asyncapi/bindings/blob/master/solace#server) | Protocol-specific information for a Solace server. +`sqs` | [SQS Server Binding](https://github.com/asyncapi/bindings/blob/master/sqs#server) | Protocol-specific information for an SQS server. +`stomp` | [STOMP Server Binding](https://github.com/asyncapi/bindings/blob/master/stomp#server) | Protocol-specific information for a STOMP server. +`redis` | [Redis Server Binding](https://github.com/asyncapi/bindings/blob/master/redis#server) | Protocol-specific information for a Redis server. +`mercure` | [Mercure Server Binding](https://github.com/asyncapi/bindings/blob/master/mercure#server) | Protocol-specific information for a Mercure server. +`ibmmq` | [IBM MQ Server Binding](https://github.com/asyncapi/bindings/blob/master/ibmmq#server-binding-object) | Protocol-specific information for an IBM MQ server. +`googlepubsub` | [Google Cloud Pub/Sub Server Binding](https://github.com/asyncapi/bindings/blob/master/googlepubsub#server) | Protocol-specific information for a Google Cloud Pub/Sub server. +`pulsar` | [Pulsar Server Binding](https://github.com/asyncapi/bindings/tree/master/pulsar#server-binding-object) | Protocol-specific information for a Pulsar server. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Channel Bindings Object + +Map describing protocol-specific definitions for a channel. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +`http` | [HTTP Channel Binding](https://github.com/asyncapi/bindings/blob/master/http/README.md#channel) | Protocol-specific information for an HTTP channel. +`ws` | [WebSockets Channel Binding](https://github.com/asyncapi/bindings/blob/master/websockets/README.md#channel) | Protocol-specific information for a WebSockets channel. +`kafka` | [Kafka Channel Binding](https://github.com/asyncapi/bindings/blob/master/kafka/README.md#channel) | Protocol-specific information for a Kafka channel. +`anypointmq` | [Anypoint MQ Channel Binding](https://github.com/asyncapi/bindings/blob/master/anypointmq/README.md#channel) | Protocol-specific information for an Anypoint MQ channel. +`amqp` | [AMQP Channel Binding](https://github.com/asyncapi/bindings/blob/master/amqp/README.md#channel) | Protocol-specific information for an AMQP 0-9-1 channel. +`amqp1` | [AMQP 1.0 Channel Binding](https://github.com/asyncapi/bindings/blob/master/amqp1/README.md#channel) | Protocol-specific information for an AMQP 1.0 channel. +`mqtt` | [MQTT Channel Binding](https://github.com/asyncapi/bindings/blob/master/mqtt/README.md#channel) | Protocol-specific information for an MQTT channel. +`mqtt5` | [MQTT 5 Channel Binding](https://github.com/asyncapi/bindings/blob/master/mqtt5#channel) | Protocol-specific information for an MQTT 5 channel. +`nats` | [NATS Channel Binding](https://github.com/asyncapi/bindings/blob/master/nats/README.md#channel) | Protocol-specific information for a NATS channel. +`jms` | [JMS Channel Binding](https://github.com/asyncapi/bindings/blob/master/jms/README.md#channel) | Protocol-specific information for a JMS channel. +`sns` | [SNS Channel Binding](https://github.com/asyncapi/bindings/blob/master/sns/README.md#channel) | Protocol-specific information for an SNS channel. +`solace` | [Solace Channel Binding](https://github.com/asyncapi/bindings/blob/master/solace#channel) | Protocol-specific information for a Solace channel. +`sqs` | [SQS Channel Binding](https://github.com/asyncapi/bindings/blob/master/sqs/README.md#channel) | Protocol-specific information for an SQS channel. +`stomp` | [STOMP Channel Binding](https://github.com/asyncapi/bindings/blob/master/stomp/README.md#channel) | Protocol-specific information for a STOMP channel. +`redis` | [Redis Channel Binding](https://github.com/asyncapi/bindings/blob/master/redis#channel) | Protocol-specific information for a Redis channel. +`mercure` | [Mercure Channel Binding](https://github.com/asyncapi/bindings/blob/master/mercure#channel) | Protocol-specific information for a Mercure channel. +`ibmmq` | [IBM MQ Channel Binding](https://github.com/asyncapi/bindings/tree/master/ibmmq#channel-binding-object) | Protocol-specific information for an IBM MQ channel. +`googlepubsub` | [Google Cloud Pub/Sub Channel Binding](https://github.com/asyncapi/bindings/tree/master/googlepubsub#channel) | Protocol-specific information for a Google Cloud Pub/Sub channel. +`pulsar` | [Pulsar Channel Binding](https://github.com/asyncapi/bindings/tree/master/pulsar#channel-binding-object) | Protocol-specific information for a Pulsar channel. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Operation Bindings Object + +Map describing protocol-specific definitions for an operation. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +`http` | [HTTP Operation Binding](https://github.com/asyncapi/bindings/blob/master/http/README.md#operation) | Protocol-specific information for an HTTP operation. +`ws` | [WebSockets Operation Binding](https://github.com/asyncapi/bindings/blob/master/websockets/README.md#operation) | Protocol-specific information for a WebSockets operation. +`kafka` | [Kafka Operation Binding](https://github.com/asyncapi/bindings/blob/master/kafka/README.md#operation) | Protocol-specific information for a Kafka operation. +`anypointmq` | [Anypoint MQ Operation Binding](https://github.com/asyncapi/bindings/blob/master/anypointmq/README.md#operation) | Protocol-specific information for an Anypoint MQ operation. +`amqp` | [AMQP Operation Binding](https://github.com/asyncapi/bindings/blob/master/amqp/README.md#operation) | Protocol-specific information for an AMQP 0-9-1 operation. +`amqp1` | [AMQP 1.0 Operation Binding](https://github.com/asyncapi/bindings/blob/master/amqp1/README.md#operation) | Protocol-specific information for an AMQP 1.0 operation. +`mqtt` | [MQTT Operation Binding](https://github.com/asyncapi/bindings/blob/master/mqtt/README.md#operation) | Protocol-specific information for an MQTT operation. +`mqtt5` | [MQTT 5 Operation Binding](https://github.com/asyncapi/bindings/blob/master/mqtt5/README.md#operation) | Protocol-specific information for an MQTT 5 operation. +`nats` | [NATS Operation Binding](https://github.com/asyncapi/bindings/blob/master/nats/README.md#operation) | Protocol-specific information for a NATS operation. +`jms` | [JMS Operation Binding](https://github.com/asyncapi/bindings/blob/master/jms/README.md#operation) | Protocol-specific information for a JMS operation. +`sns` | [SNS Operation Binding](https://github.com/asyncapi/bindings/blob/master/sns/README.md#operation) | Protocol-specific information for an SNS operation. +`solace` | [Solace Operation Binding](https://github.com/asyncapi/bindings/blob/master/solace#operation) | Protocol-specific information for a Solace operation. +`sqs` | [SQS Operation Binding](https://github.com/asyncapi/bindings/blob/master/sqs/README.md#operation) | Protocol-specific information for an SQS operation. +`stomp` | [STOMP Operation Binding](https://github.com/asyncapi/bindings/blob/master/stomp/README.md#operation) | Protocol-specific information for a STOMP operation. +`redis` | [Redis Operation Binding](https://github.com/asyncapi/bindings/blob/master/redis#operation) | Protocol-specific information for a Redis operation. +`mercure` | [Mercure Operation Binding](https://github.com/asyncapi/bindings/blob/master/mercure#operation) | Protocol-specific information for a Mercure operation. +`googlepubsub` | [Google Cloud Pub/Sub Operation Binding](https://github.com/asyncapi/bindings/blob/master/googlepubsub#operation) | Protocol-specific information for a Google Cloud Pub/Sub operation. +`ibmmq` | [IBM MQ Operation Binding](https://github.com/asyncapi/bindings/blob/master/ibmmq#operation-binding-object) | Protocol-specific information for an IBM MQ operation. +`pulsar` | [Pulsar Operation Binding](https://github.com/asyncapi/bindings/tree/master/pulsar#operation-binding-fields) | Protocol-specific information for a Pulsar operation. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Message Bindings Object + +Map describing protocol-specific definitions for a message. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +`http` | [HTTP Message Binding](https://github.com/asyncapi/bindings/blob/master/http/README.md#message) | Protocol-specific information for an HTTP message, i.e., a request or a response. +`ws` | [WebSockets Message Binding](https://github.com/asyncapi/bindings/blob/master/websockets/README.md#message) | Protocol-specific information for a WebSockets message. +`kafka` | [Kafka Message Binding](https://github.com/asyncapi/bindings/blob/master/kafka/README.md#message) | Protocol-specific information for a Kafka message. +`anypointmq` | [Anypoint MQ Message Binding](https://github.com/asyncapi/bindings/blob/master/anypointmq/README.md#message) | Protocol-specific information for an Anypoint MQ message. +`amqp` | [AMQP Message Binding](https://github.com/asyncapi/bindings/blob/master/amqp/README.md#message) | Protocol-specific information for an AMQP 0-9-1 message. +`amqp1` | [AMQP 1.0 Message Binding](https://github.com/asyncapi/bindings/blob/master/amqp1/README.md#message) | Protocol-specific information for an AMQP 1.0 message. +`mqtt` | [MQTT Message Binding](https://github.com/asyncapi/bindings/blob/master/mqtt/README.md#message) | Protocol-specific information for an MQTT message. +`mqtt5` | [MQTT 5 Message Binding](https://github.com/asyncapi/bindings/blob/master/mqtt5/README.md#message) | Protocol-specific information for an MQTT 5 message. +`nats` | [NATS Message Binding](https://github.com/asyncapi/bindings/blob/master/nats/README.md#message) | Protocol-specific information for a NATS message. +`jms` | [JMS Message Binding](https://github.com/asyncapi/bindings/blob/master/jms/README.md#message) | Protocol-specific information for a JMS message. +`sns` | [SNS Message Binding](https://github.com/asyncapi/bindings/blob/master/sns/README.md#message) | Protocol-specific information for an SNS message. +`solace` | [Solace Server Binding](https://github.com/asyncapi/bindings/blob/master/solace#message) | Protocol-specific information for a Solace message. +`sqs` | [SQS Message Binding](https://github.com/asyncapi/bindings/blob/master/sqs/README.md#message) | Protocol-specific information for an SQS message. +`stomp` | [STOMP Message Binding](https://github.com/asyncapi/bindings/blob/master/stomp/README.md#message) | Protocol-specific information for a STOMP message. +`redis` | [Redis Message Binding](https://github.com/asyncapi/bindings/blob/master/redis#message) | Protocol-specific information for a Redis message. +`mercure` | [Mercure Message Binding](https://github.com/asyncapi/bindings/blob/master/mercure#message) | Protocol-specific information for a Mercure message. +`ibmmq` | [IBM MQ Message Binding](https://github.com/asyncapi/bindings/tree/master/ibmmq#message-binding-object) | Protocol-specific information for an IBM MQ message. +`googlepubsub` | [Google Cloud Pub/Sub Message Binding](https://github.com/asyncapi/bindings/tree/master/googlepubsub#message) | Protocol-specific information for a Google Cloud Pub/Sub message. +`pulsar` | [Pulsar Message Binding](https://github.com/asyncapi/bindings/tree/master/pulsar#message-binding-fields) | Protocol-specific information for a Pulsar message. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Message Object + +Describes a message received on a given channel and operation. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +headers | [Multi Format Schema Object](#multiFormatSchemaObject) | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | Schema definition of the application headers. Schema MUST be a map of key-value pairs. It **MUST NOT** define the protocol headers. If this is a [Schema Object](#schemaObject), then the `schemaFormat` will be assumed to be "application/vnd.aai.asyncapi+json;version=`asyncapi`" where the version is equal to the [AsyncAPI Version String](#A2SVersionString). +payload | [Multi Format Schema Object](#multiFormatSchemaObject) | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | Definition of the message payload. If this is a [Schema Object](#schemaObject), then the `schemaFormat` will be assumed to be "application/vnd.aai.asyncapi+json;version=`asyncapi`" where the version is equal to the [AsyncAPI Version String](#A2SVersionString). +correlationId | [Correlation ID Object](#correlationIdObject) | [Reference Object](#referenceObject) | Definition of the correlation ID used for message tracing or matching. +contentType | `string` | The content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. `application/json`). When omitted, the value MUST be the one specified on the [defaultContentType](#defaultContentTypeString) field. +name | `string` | A machine-friendly name for the message. +title | `string` | A human-friendly title for the message. +summary | `string` | A short summary of what the message is about. +description | `string` | A verbose explanation of the message. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping and categorization of messages. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this message. +bindings | [Message Bindings Object](#messageBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. +examples | [[Message Example Object](#messageExampleObject)] | List of examples. +traits | [[Message Trait Object](#messageTraitObject) | [Reference Object](#referenceObject)] | A list of traits to apply to the message object. Traits MUST be merged using [traits merge mechanism](#traits-merge-mechanism). The resulting object MUST be a valid [Message Object](#messageObject). + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Message Object Example + + +```json +{ + "name": "UserSignup", + "title": "User signup", + "summary": "Action to sign a user up.", + "description": "A longer description", + "contentType": "application/json", + "tags": [ + { "name": "user" }, + { "name": "signup" }, + { "name": "register" } + ], + "headers": { + "type": "object", + "properties": { + "correlationId": { + "description": "Correlation ID set by application", + "type": "string" + }, + "applicationInstanceId": { + "description": "Unique identifier for a given instance of the publishing application", + "type": "string" + } + } + }, + "payload": { + "type": "object", + "properties": { + "user": { + "$ref": "#/components/schemas/userCreate" + }, + "signup": { + "$ref": "#/components/schemas/signup" + } + } + }, + "correlationId": { + "description": "Default Correlation ID", + "location": "$message.header#/correlationId" + }, + "traits": [ + { "$ref": "#/components/messageTraits/commonHeaders" } + ], + "examples": [ + { + "name": "SimpleSignup", + "summary": "A simple UserSignup example message", + "headers": { + "correlationId": "my-correlation-id", + "applicationInstanceId": "myInstanceId" + }, + "payload": { + "user": { + "someUserKey": "someUserValue" + }, + "signup": { + "someSignupKey": "someSignupValue" + } + } + } + ] +} +``` + + +```yaml +name: UserSignup +title: User signup +summary: Action to sign a user up. +description: A longer description +contentType: application/json +tags: + - name: user + - name: signup + - name: register +headers: + type: object + properties: + correlationId: + description: Correlation ID set by application + type: string + applicationInstanceId: + description: Unique identifier for a given instance of the publishing application + type: string +payload: + type: object + properties: + user: + $ref: '#/components/schemas/userCreate' + signup: + $ref: '#/components/schemas/signup' +correlationId: + description: Default Correlation ID + location: $message.header#/correlationId +traits: + - $ref: '#/components/messageTraits/commonHeaders' +examples: + - name: SimpleSignup + summary: A simple UserSignup example message + headers: + correlationId: my-correlation-id + applicationInstanceId: myInstanceId + payload: + user: + someUserKey: someUserValue + signup: + someSignupKey: someSignupValue +``` + +Example using Avro to define the payload: + + +```json +{ + "name": "UserSignup", + "title": "User signup", + "summary": "Action to sign a user up.", + "description": "A longer description", + "tags": [ + { "name": "user" }, + { "name": "signup" }, + { "name": "register" } + ], + "payload": { + "schemaFormat": "application/vnd.apache.avro+json;version=1.9.0", + "schema": { + "$ref": "./user-create.avsc" + } + } +} +``` + + +```yaml +name: UserSignup +title: User signup +summary: Action to sign a user up. +description: A longer description +tags: + - name: user + - name: signup + - name: register +payload: + schemaFormat: 'application/vnd.apache.avro+yaml;version=1.9.0' + schema: + $ref: './user-create.avsc' +``` + +#### Message Trait Object + +Describes a trait that MAY be applied to a [Message Object](#messageObject). This object MAY contain any property from the [Message Object](#messageObject), except `payload` and `traits`. + +If you're looking to apply traits to an operation, see the [Operation Trait Object](#operationTraitObject). + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +headers | [Multi Format Schema Object](#multiFormatSchemaObject) | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | Schema definition of the application headers. Schema MUST be a map of key-value pairs. It **MUST NOT** define the protocol headers. If this is a [Schema Object](#schemaObject), then the `schemaFormat` will be assumed to be "application/vnd.aai.asyncapi+json;version=`asyncapi`" where the version is equal to the [AsyncAPI Version String](#A2SVersionString). +correlationId | [Correlation ID Object](#correlationIdObject) | [Reference Object](#referenceObject) | Definition of the correlation ID used for message tracing or matching. +contentType | `string` | The content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. `application/json`). When omitted, the value MUST be the one specified on the [defaultContentType](#defaultContentTypeString) field. +name | `string` | A machine-friendly name for the message. +title | `string` | A human-friendly title for the message. +summary | `string` | A short summary of what the message is about. +description | `string` | A verbose explanation of the message. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +tags | [Tags Object](#tagsObject) | A list of tags for logical grouping and categorization of messages. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this message. +bindings | [Message Bindings Object](#messageBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. +examples | [[Message Example Object](#messageExampleObject)] | List of examples. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Message Trait Object Example + + +```json +{ + "contentType": "application/json" +} +``` + + +```yaml +contentType: application/json +``` + +#### Message Example Object + +Message Example Object represents an example of a [Message Object](#messageObject) and MUST contain either **headers** and/or **payload** fields. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +headers | `Map[string, any]` | The value of this field MUST validate against the [Message Object's headers](#messageObjectHeaders) field. +payload | `Map[string, any]` | The value of this field MUST validate against the [Message Object's payload](#messageObjectPayload) field. +name | `string` | A machine-friendly name. +summary | `string` | A short summary of what the example is about. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Message Example Object Example + + +```json +{ + "name": "SimpleSignup", + "summary": "A simple UserSignup example message", + "headers": { + "correlationId": "my-correlation-id", + "applicationInstanceId": "myInstanceId" + }, + "payload": { + "user": { + "someUserKey": "someUserValue" + }, + "signup": { + "someSignupKey": "someSignupValue" + } + } +} +``` + + +```yaml +name: SimpleSignup +summary: A simple UserSignup example message +headers: + correlationId: my-correlation-id + applicationInstanceId: myInstanceId +payload: + user: + someUserKey: someUserValue + signup: + someSignupKey: someSignupValue +``` + +#### Tags Object + +A Tags object is a list of [Tag Objects](#tagObject). An [Tag Object](#tagObject) in a list can be referenced by [Reference Object](#referenceObject). + +#### Tag Object + +Allows adding meta data to a single tag. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +name | `string` | **REQUIRED.** The name of the tag. +description | `string` | A short description for the tag. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this tag. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Tag Object Example + + +```json +{ + "name": "user", + "description": "User-related messages" +} +``` + + +```yaml +name: user +description: User-related messages +``` + +#### External Documentation Object + +Allows referencing an external resource for extended documentation. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +description | `string` | A short description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +url | `string` | **REQUIRED.** The URL for the target documentation. This MUST be in the form of an absolute URL. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### External Documentation Object Example + + +```json +{ + "description": "Find more info here", + "url": "https://example.com" +} +``` + + +```yaml +description: Find more info here +url: https://example.com +``` + +#### Reference Object + +A simple object to allow referencing other components in the specification, internally and externally. + +The Reference Object is defined by [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and follows the same structure, behavior and rules. A JSON Reference SHALL only be used to refer to a schema that is formatted in either JSON or YAML. In the case of a YAML-formatted Schema, the JSON Reference SHALL be applied to the JSON representation of that schema. The JSON representation SHALL be made by applying the conversion described [here](#format). + +For this specification, reference resolution is done as defined by the JSON Reference specification and not by the JSON Schema specification. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +$ref | `string` | **REQUIRED.** The reference string. + +This object cannot be extended with additional properties and any properties added SHALL be ignored. + +##### Reference Object Example + + +```json +{ + "$ref": "#/components/schemas/Pet" +} +``` + + +```yaml + $ref: '#/components/schemas/Pet' +``` + +#### Components Object + +Holds a set of reusable objects for different aspects of the AsyncAPI specification. +All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. + +##### Fixed Fields + +Field Name | Type | Description +---|:---|--- + schemas | Map[`string`, [Multi Format Schema Object](#multiFormatSchemaObject) \| [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Object](#schemaObject). If this is a [Schema Object](#schemaObject), then the `schemaFormat` will be assumed to be "application/vnd.aai.asyncapi+json;version=`asyncapi`" where the version is equal to the [AsyncAPI Version String](#A2SVersionString). + servers | Map[`string`, [Server Object](#serverObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Server Objects](#serverObject). + channels | Map[`string`, [Channel Object](#channelObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Channel Objects](#channelObject). + operations | Map[`string`, [Operation Object](#operationObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Objects](#operationObject). + messages | Map[`string`, [Message Object](#messageObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Message Objects](#messageObject). + securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). + serverVariables | Map[`string`, [Server Variable Object](#serverVariableObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Server Variable Objects](#serverVariableObject). + parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). + correlationIds | Map[`string`, [Correlation ID Object](#correlationIdObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Correlation ID Objects](#correlationIdObject). +replies | Map[`string`, [Operation Reply Object](#operationReplyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Reply Objects](#operationReplyObject). + replyAddresses | Map[`string`, [Operation Reply Address Object](#operationReplyAddressObject) | [Reference Object](#referenceObject)] | An object to hold reusable [Operation Reply Address Objects](#operationReplyAddressObject). + externalDocs | Map[`string`, [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [External Documentation Objects](#externalDocumentationObject). + tags | Map[`string`, [Tag Object](#tagObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Tag Objects](#tagObject). + operationTraits | Map[`string`, [Operation Trait Object](#operationTraitObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Trait Objects](#operationTraitObject). + messageTraits | Map[`string`, [Message Trait Object](#messageTraitObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Message Trait Objects](#messageTraitObject). + serverBindings | Map[`string`, [Server Bindings Object](#serverBindingsObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Server Bindings Objects](#serverBindingsObject). + channelBindings | Map[`string`, [Channel Bindings Object](#channelBindingsObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Channel Bindings Objects](#channelBindingsObject). + operationBindings | Map[`string`, [Operation Bindings Object](#operationBindingsObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Bindings Objects](#operationBindingsObject). + messageBindings | Map[`string`, [Message Bindings Object](#messageBindingsObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Message Bindings Objects](#messageBindingsObject). + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +All the fixed fields declared above are objects that MUST use keys that match the regular expression: `^[a-zA-Z0-9\.\-_]+$`. + +Field Name Examples: + +```text +User +User_1 +User_Name +user-name +my.org.User +``` + +##### Components Object Example + + +```json +{ + "components": { + "schemas": { + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "AvroExample": { + "schemaFormat": "application/vnd.apache.avro+json;version=1.9.0", + "schema": { + "$ref": "./user-create.avsc" + } + } + }, + "servers": { + "development": { + "host": "{stage}.in.mycompany.com:{port}", + "description": "RabbitMQ broker", + "protocol": "amqp", + "protocolVersion": "0-9-1", + "variables": { + "stage": { + "$ref": "#/components/serverVariables/stage" + }, + "port": { + "$ref": "#/components/serverVariables/port" + } + } + } + }, + "serverVariables": { + "stage": { + "default": "demo", + "description": "This value is assigned by the service provider, in this example `mycompany.com`" + }, + "port": { + "enum": ["5671", "5672"], + "default": "5672" + } + }, + "channels": { + "user/signedup": { + "subscribe": { + "message": { + "$ref": "#/components/messages/userSignUp" + } + } + } + }, + "messages": { + "userSignUp": { + "summary": "Action to sign a user up.", + "description": "Multiline description of what this action does.\nHere you have another line.\n", + "tags": [ + { + "name": "user" + }, + { + "name": "signup" + } + ], + "headers": { + "type": "object", + "properties": { + "applicationInstanceId": { + "description": "Unique identifier for a given instance of the publishing application", + "type": "string" + } + } + }, + "payload": { + "type": "object", + "properties": { + "user": { + "$ref": "#/components/schemas/userCreate" + }, + "signup": { + "$ref": "#/components/schemas/signup" + } + } + } + } + }, + "parameters": { + "userId": { + "description": "Id of the user." + } + }, + "correlationIds": { + "default": { + "description": "Default Correlation ID", + "location": "$message.header#/correlationId" + } + }, + "messageTraits": { + "commonHeaders": { + "headers": { + "type": "object", + "properties": { + "my-app-header": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + } + } + } + } + } +} +``` + + +```yaml +components: + schemas: + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + AvroExample: + schemaFormat: 'application/vnd.apache.avro+json;version=1.9.0' + schema: + $ref: './user-create.avsc' + servers: + development: + host: '{stage}.in.mycompany.com:{port}' + description: RabbitMQ broker + protocol: amqp + protocolVersion: 0-9-1 + variables: + stage: + $ref: '#/components/serverVariables/stage' + port: + $ref: '#/components/serverVariables/port' + serverVariables: + stage: + default: demo + description: | + This value is assigned by the service provider, in this example + `mycompany.com` + port: + enum: + - '5671' + - '5672' + default: '5672' + channels: + user/signedup: + subscribe: + message: + $ref: '#/components/messages/userSignUp' + messages: + userSignUp: + summary: Action to sign a user up. + description: | + Multiline description of what this action does. + Here you have another line. + tags: + - name: user + - name: signup + headers: + type: object + properties: + applicationInstanceId: + description: | + Unique identifier for a given instance of the publishing + application + type: string + payload: + type: object + properties: + user: + $ref: '#/components/schemas/userCreate' + signup: + $ref: '#/components/schemas/signup' + parameters: + userId: + description: Id of the user. + correlationIds: + default: + description: Default Correlation ID + location: '$message.header#/correlationId' + messageTraits: + commonHeaders: + headers: + type: object + properties: + my-app-header: + type: integer + minimum: 0 + maximum: 100 +``` + +#### Multi Format Schema Object + +The Multi Format Schema Object represents a schema definition. It differs from the [Schema Object](#schemaObject) in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.). + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +schemaFormat | `string` | **Required**. A string containing the name of the schema format that is used to define the information. If `schemaFormat` is missing, it MUST default to `application/vnd.aai.asyncapi+json;version={{asyncapi}}` where `{{asyncapi}}` matches the [AsyncAPI Version String](#A2SVersionString). In such a case, this would make the Multi Format Schema Object equivalent to the [Schema Object](#schemaObject). When using [Reference Object](#referenceObject) within the schema, the `schemaFormat` of the resource being referenced MUST match the `schemaFormat` of the schema that contains the initial reference. For example, if you reference Avro `schema`, then `schemaFormat` of referencing resource and the resource being reference MUST match.

Check out the [supported schema formats table](#multiFormatSchemaFormatTable) for more information. Custom values are allowed but their implementation is OPTIONAL. A custom value MUST NOT refer to one of the schema formats listed in the [table](#multiFormatSchemaFormatTable).

When using [Reference Objects](#referenceObject) within the schema, the `schemaFormat` of the referenced resource MUST match the `schemaFormat` of the schema containing the reference. +schema | `any` | **Required**. Definition of the message payload. It can be of any type but defaults to [Schema Object](#schemaObject). It MUST match the schema format defined in [`schemaFormat`](#multiFormatSchemaObjectSchemaFormat), including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Schema formats table + +The following table contains a set of values that every implementation MUST support. + +Name | Allowed values | Notes +---|:---:|--- +[AsyncAPI 3.0.0 Schema Object](#schemaObject) | `application/vnd.aai.asyncapi;version=3.0.0`, `application/vnd.aai.asyncapi+json;version=3.0.0`, `application/vnd.aai.asyncapi+yaml;version=3.0.0` | This is the default when a `schemaFormat` is not provided. +[JSON Schema Draft 07](https://json-schema.org/specification-links.html#draft-7) | `application/schema+json;version=draft-07`, `application/schema+yaml;version=draft-07` | + +The following table contains a set of values that every implementation is RECOMMENDED to support. + +Name | Allowed values | Notes +---|:---:|--- +[Avro 1.9.0 schema](https://avro.apache.org/docs/1.9.0/spec.html#schemas) | `application/vnd.apache.avro;version=1.9.0`, `application/vnd.apache.avro+json;version=1.9.0`, `application/vnd.apache.avro+yaml;version=1.9.0` | +[OpenAPI 3.0.0 Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject) | `application/vnd.oai.openapi;version=3.0.0`, `application/vnd.oai.openapi+json;version=3.0.0`, `application/vnd.oai.openapi+yaml;version=3.0.0` | +[RAML 1.0 data type](https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/) | `application/raml+yaml;version=1.0` | +[Protocol Buffers](https://protobuf.dev/) | `application/vnd.google.protobuf;version=2`, `application/vnd.google.protobuf;version=3` | + +##### Multi Format Schema Object Examples + +###### Multi Format Schema Object Example with Avro + + +```yaml +channels: + example: + messages: + myMessage: + payload: + schemaFormat: 'application/vnd.apache.avro;version=1.9.0' + schema: + type: record + name: User + namespace: com.company + doc: User information + fields: + - name: displayName + type: string + - name: age + type: int +``` + +#### Schema Object + +The Schema Object allows the definition of input and output data types. +These types can be objects, but also primitives and arrays. This object is a superset of the [JSON Schema Specification Draft 07](https://json-schema.org/). The empty schema (which allows any instance to validate) MAY be represented by the `boolean` value `true` and a schema which allows no instance to validate MAY be represented by the `boolean` value `false`. + +Further information about the properties can be found in [JSON Schema Core](https://tools.ietf.org/html/draft-handrews-json-schema-01) and [JSON Schema Validation](https://tools.ietf.org/html/draft-handrews-json-schema-validation-01). +Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here. For other formats (e.g., Avro, RAML, etc) see [Multi Format Schema Object](#multiFormatSchemaObject). + +##### Properties + +The AsyncAPI Schema Object is a JSON Schema vocabulary which extends JSON Schema Core and Validation vocabularies. As such, any keyword available for those vocabularies is by definition available in AsyncAPI, and will work the exact same way, including but not limited to: + +- title +- type +- required +- multipleOf +- maximum +- exclusiveMaximum +- minimum +- exclusiveMinimum +- maxLength +- minLength +- pattern (This string SHOULD be a valid regular expression, according to the [ECMA 262 regular expression](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) dialect) +- maxItems +- minItems +- uniqueItems +- maxProperties +- minProperties +- enum +- const +- examples +- if / then / else +- readOnly +- writeOnly +- properties +- patternProperties +- additionalProperties +- additionalItems +- items +- propertyNames +- contains +- allOf +- oneOf +- anyOf +- not + +The following properties are taken from the JSON Schema definition but their definitions were adjusted to the AsyncAPI Specification. + +- description - [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the AsyncAPI Specification offers a few additional predefined formats. +- default - Use it to specify that property has a predefined value if no other value is present. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, of `type` is `string`, then `default` can be `"foo"` but cannot be `1`. + +Alternatively, any time a Schema Object can be used, a [Reference Object](#referenceObject) can be used in its place. This allows referencing definitions in place of defining them inline. It is appropriate to clarify that the `$ref` keyword MUST follow the behavior described by [Reference Object](#referenceObject) instead of the one in [JSON Schema definition](https://json-schema.org/understanding-json-schema/structuring.html#ref). + +In addition to the JSON Schema fields, the following AsyncAPI vocabulary fields MAY be used for further schema documentation: + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +discriminator | `string` | Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the `required` property list. When used, the value MUST be the name of this schema or any schema that inherits it. See [Composition and Inheritance](#schemaComposition) for more details. +externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this schema. + deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is `false`. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +###### Composition and Inheritance (Polymorphism) + +The AsyncAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. +`allOf` takes in an array of object definitions that are validated _independently_ but together compose a single object. + +While composition offers model extensibility, it does not imply a hierarchy between the models. +To support polymorphism, AsyncAPI Specification adds the support of the `discriminator` field. +When used, the `discriminator` will be the name of the property used to decide which schema definition is used to validate the structure of the model. +As such, the `discriminator` field MUST be a required field. +There are two ways to define the value of a discriminator for an inheriting instance. + +- Use the schema's name. +- Override the schema's name by overriding the property with a new value. If exists, this takes precedence over the schema's name. + +As such, inline schema definitions, which do not have a given id, _cannot_ be used in polymorphism. + +##### Schema Object Examples + +###### Primitive Sample + + +```json +{ + "type": "string", + "format": "email" +} +``` + + +```yaml +type: string +format: email +``` + +###### Simple Model + + +```json +{ + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "address": { + "$ref": "#/components/schemas/Address" + }, + "age": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + } +} +``` + + +```yaml +type: object +required: +- name +properties: + name: + type: string + address: + $ref: '#/components/schemas/Address' + age: + type: integer + format: int32 + minimum: 0 +``` + +###### Model with Map/Dictionary Properties + +For a simple string to string mapping: + + +```json +{ + "type": "object", + "additionalProperties": { + "type": "string" + } +} +``` + + +```yaml +type: object +additionalProperties: + type: string +``` + +For a string to model mapping: + + +```json +{ + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/ComplexModel" + } +} +``` + + +```yaml +type: object +additionalProperties: + $ref: '#/components/schemas/ComplexModel' +``` + +###### Model with Example + + +```json +{ + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "examples": [ + { + "name": "Puma", + "id": 1 + } + ] +} +``` + + +```yaml +type: object +properties: + id: + type: integer + format: int64 + name: + type: string +required: +- name +examples: +- name: Puma + id: 1 +``` + +###### Model with Boolean Schemas + + +```json +{ + "type": "object", + "required": [ + "anySchema" + ], + "properties": { + "anySchema": true, + "cannotBeDefined": false + } +} +``` + + +```yaml +type: object +required: +- anySchema +properties: + anySchema: true + cannotBeDefined: false +``` + +###### Models with Composition + + +```json +{ + "schemas": { + "ErrorModel": { + "type": "object", + "required": [ + "message", + "code" + ], + "properties": { + "message": { + "type": "string" + }, + "code": { + "type": "integer", + "minimum": 100, + "maximum": 600 + } + } + }, + "ExtendedErrorModel": { + "allOf": [ + { + "$ref": "#/components/schemas/ErrorModel" + }, + { + "type": "object", + "required": [ + "rootCause" + ], + "properties": { + "rootCause": { + "type": "string" + } + } + } + ] + } + } +} +``` + + +```yaml +schemas: + ErrorModel: + type: object + required: + - message + - code + properties: + message: + type: string + code: + type: integer + minimum: 100 + maximum: 600 + ExtendedErrorModel: + allOf: + - $ref: '#/components/schemas/ErrorModel' + - type: object + required: + - rootCause + properties: + rootCause: + type: string +``` + +###### Models with Polymorphism Support + + +```json +{ + "schemas": { + "Pet": { + "type": "object", + "discriminator": "petType", + "properties": { + "name": { + "type": "string" + }, + "petType": { + "type": "string" + } + }, + "required": [ + "name", + "petType" + ] + }, + "Cat": { + "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + }, + { + "type": "object", + "properties": { + "huntingSkill": { + "type": "string", + "description": "The measured skill for hunting", + "enum": [ + "clueless", + "lazy", + "adventurous", + "aggressive" + ] + } + }, + "required": [ + "huntingSkill" + ] + } + ] + }, + "Dog": { + "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + }, + { + "type": "object", + "properties": { + "packSize": { + "type": "integer", + "format": "int32", + "description": "the size of the pack the dog is from", + "minimum": 0 + } + }, + "required": [ + "packSize" + ] + } + ] + }, + "StickInsect": { + "description": "A representation of an Australian walking stick. Note that `StickBug` will be used as the discriminator value.", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + }, + { + "type": "object", + "properties": { + "petType": { + "const": "StickBug" + }, + "color": { + "type": "string" + } + }, + "required": [ + "color" + ] + } + ] + } + } +} +``` + + +```yaml +schemas: + Pet: + type: object + discriminator: petType + properties: + name: + type: string + petType: + type: string + required: + - name + - petType + ## applies to instances with `petType: "Cat"` + ## because that is the schema name + Cat: + description: A representation of a cat + allOf: + - $ref: '#/components/schemas/Pet' + - type: object + properties: + huntingSkill: + type: string + description: The measured skill for hunting + enum: + - clueless + - lazy + - adventurous + - aggressive + required: + - huntingSkill + ## applies to instances with `petType: "Dog"` + ## because that is the schema name + Dog: + description: A representation of a dog + allOf: + - $ref: '#/components/schemas/Pet' + - type: object + properties: + packSize: + type: integer + format: int32 + description: the size of the pack the dog is from + minimum: 0 + required: + - packSize + ## applies to instances with `petType: "StickBug"` + ## because that is the required value of the discriminator field, + ## overriding the schema name + StickInsect: + description: A representation of an Australian walking stick + allOf: + - $ref: '#/components/schemas/Pet' + - type: object + properties: + petType: + const: StickBug + color: + type: string + required: + - color +``` + +#### Security Scheme Object + +Defines a security scheme that can be used by the operations. Supported schemes are: + +- User/Password. +- API key (either as user or as password). +- X.509 certificate. +- End-to-end encryption (either symmetric or asymmetric). +- HTTP authentication. +- HTTP API key. +- OAuth2's common flows (Implicit, Resource Owner Protected Credentials, Client Credentials and Authorization Code) as defined in [RFC6749](https://tools.ietf.org/html/rfc6749). +- [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06). +- SASL (Simple Authentication and Security Layer) as defined in [RFC4422](https://tools.ietf.org/html/rfc4422). + +##### Fixed Fields + +Field Name | Type | Applies To | Description +---|:---:|---|--- +type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"userPassword"`, `"apiKey"`, `"X509"`, `"symmetricEncryption"`, `"asymmetricEncryption"`, `"httpApiKey"`, `"http"`, `"oauth2"`, `"openIdConnect"`, `"plain"`, `"scramSha256"`, `"scramSha512"`, and `"gssapi"`. +description | `string` | Any | A short description for security scheme. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. +name | `string` | `httpApiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. +in | `string` | `apiKey` \| `httpApiKey` | **REQUIRED**. The location of the API key. Valid values are `"user"` and `"password"` for `apiKey` and `"query"`, `"header"` or `"cookie"` for `httpApiKey`. +scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authorization scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). +bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. +flows | [OAuth Flows Object](#oauthFlowsObject) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. +openIdConnectUrl | `string` | `openIdConnect` | **REQUIRED**. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of an absolute URL. +scopes | [`string`] | `oauth2` \| `openIdConnect` | List of the needed scope names. An empty array means no scopes are needed. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Security Scheme Object Example + +###### User/Password Authentication Sample + + +```json +{ + "type": "userPassword" +} +``` + + +```yaml +type: userPassword +``` + +###### API Key Authentication Sample + + +```json +{ + "type": "apiKey", + "in": "user" +} +``` + + +```yaml +type: apiKey +in: user +``` + +###### X.509 Authentication Sample + + +```json +{ + "type": "X509" +} +``` + + +```yaml +type: X509 +``` + +###### End-to-end Encryption Authentication Sample + + +```json +{ + "type": "symmetricEncryption" +} +``` + + +```yaml +type: symmetricEncryption +``` + +###### Basic Authentication Sample + + +```json +{ + "type": "http", + "scheme": "basic" +} +``` + + +```yaml +type: http +scheme: basic +``` + +###### API Key Sample + + +```json +{ + "type": "httpApiKey", + "name": "api_key", + "in": "header" +} +``` + + +```yaml +type: httpApiKey +name: api_key +in: header +``` + +###### JWT Bearer Sample + + +```json +{ + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" +} +``` + + +```yaml +type: http +scheme: bearer +bearerFormat: JWT +``` + +###### Implicit OAuth2 Sample + + +```json +{ + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + }, + "scopes": [ + "write:pets" + ] +} +``` + + +```yaml +type: oauth2 +flows: + implicit: + authorizationUrl: https://example.com/api/oauth/dialog + availableScopes: + write:pets: modify pets in your account + read:pets: read your pets +scopes: + - 'write:pets' +``` + +###### SASL Sample + + +```json +{ + "type": "scramSha512" +} +``` + + +```yaml +type: scramSha512 +``` + +#### OAuth Flows Object + +Allows configuration of the supported OAuth Flows. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +implicit| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Implicit flow. +password| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Resource Owner Protected Credentials flow. +clientCredentials| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Client Credentials flow. +authorizationCode| [OAuth Flow Object](#oauthFlowObject) | Configuration for the OAuth Authorization Code flow. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### OAuth Flow Object + +Configuration details for a supported OAuth Flow + +##### Fixed Fields + +Field Name | Type | Applies To | Description +---|:---:|---|--- +authorizationUrl | `string` | `oauth2` (`"implicit"`, `"authorizationCode"`) | **REQUIRED**. The authorization URL to be used for this flow. This MUST be in the form of an absolute URL. +tokenUrl | `string` | `oauth2` (`"password"`, `"clientCredentials"`, `"authorizationCode"`) | **REQUIRED**. The token URL to be used for this flow. This MUST be in the form of an absolute URL. +refreshUrl | `string` | `oauth2` | The URL to be used for obtaining refresh tokens. This MUST be in the form of an absolute URL. +availableScopes | Map[`string`, `string`] | `oauth2` | **REQUIRED**. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### OAuth Flow Object Examples + +###### clientCredentials Oauth Flow Object Example + + +```json +{ + "tokenUrl": "https://example.com/api/oauth/token", + "availableScopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } +} +``` + +```yaml +tokenUrl: https://example.com/api/oauth/token +availableScopes: + write:pets: modify pets in your account + read:pets: read your pets +``` + +### Correlation ID Object + +An object that specifies an identifier at design time that can used for message tracing and correlation. + +For specifying and computing the location of a Correlation ID, a [runtime expression](#runtimeExpression) is used. + +#### Fixed Fields + +Field Name | Type | Description +---|:---|--- +description | `string` | An optional description of the identifier. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +location | `string` | **REQUIRED.** A [runtime expression](#runtimeExpression) that specifies the location of the correlation ID. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Examples + + +```json +{ + "description": "Default Correlation ID", + "location": "$message.header#/correlationId" +} +``` + + +```yaml +description: Default Correlation ID +location: $message.header#/correlationId +``` + +### Runtime Expression + +A runtime expression allows values to be defined based on information that will be available within the message. +This mechanism is used by [Correlation ID Object](#correlationIdObject) and [Operation Reply Address Object](#operationReplyAddressObject). + +The runtime expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax: + +```text + expression = ( "$message" "." source ) + source = ( header-reference | payload-reference ) + header-reference = "header" ["#" fragment] + payload-reference = "payload" ["#" fragment] + fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901) +``` + +The table below provides examples of runtime expressions and examples of their use in a value: + +#### Examples + +Source Location | Example expression | Notes +---|:---|:---| +Message Header Property | `$message.header#/MQMD/CorrelId` | Correlation ID is set using the `CorrelId` value from the `MQMD` header. +Message Payload Property | `$message.payload#/messageId` | Correlation ID is set using the `messageId` value from the message payload. + +Runtime expressions preserve the type of the referenced value. + +### Traits Merge Mechanism + +Traits MUST be merged with the target object using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm in the same order they are defined. A property on a trait MUST NOT override the same property on the target object. + +#### Example + +An object like the following: + +```yaml +description: A longer description. +traits: + - name: UserSignup + description: Description from trait. + - tags: + - name: user +``` + +Would look like the following after applying traits: + +```yaml +name: UserSignup +description: A longer description. +tags: + - name: user +``` + +### Specification Extensions + +While the AsyncAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points. + +The extensions properties are implemented as patterned fields that are always prefixed by `"x-"`. + +Field Pattern | Type | Description +---|:---:|--- +`^x-[\w\d\.\x2d_]+$` | Any | Allows extensions to the AsyncAPI Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. Can have any valid JSON format value. + +The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced). + +### Data Type Formats + +Primitives have an optional modifier property: `format`. +The AsyncAPI specification uses several known formats to more finely define the data type being used. +However, the `format` property is an open `string`-valued property, and can have any value to support documentation needs. +Formats such as `"email"`, `"uuid"`, etc., can be used even though they are not defined by this specification. +Types that are not accompanied by a `format` property follow their definition from the JSON Schema. +Tools that do not recognize a specific `format` MAY default back to the `type` alone, as if the `format` was not specified. + +The formats defined by the AsyncAPI Specification are: + +Common Name | `type` | [`format`](#dataTypeFormat) | Comments +----------- | ------ | -------- | -------- +integer | `integer` | `int32` | signed 32 bits +long | `integer` | `int64` | signed 64 bits +float | `number` | `float` | | +double | `number` | `double` | | +string | `string` | | | +byte | `string` | `byte` | base64 encoded characters +binary | `string` | `binary` | any sequence of octets +boolean | `boolean` | | | +date | `string` | `date` | As defined by `full-date` - [RFC3339](https://www.rfc-editor.org/rfc/rfc3339.html#section-5.6) +dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](https://www.rfc-editor.org/rfc/rfc3339.html#section-5.6) +password | `string` | `password` | Used to hint UIs the input needs to be obscured. diff --git a/src/main/resources/specs/asyncapi/asyncapi-3.0.yaml b/src/main/resources/specs/asyncapi/asyncapi-3.0.yaml new file mode 100755 index 00000000..33a0d3ec --- /dev/null +++ b/src/main/resources/specs/asyncapi/asyncapi-3.0.yaml @@ -0,0 +1,876 @@ +name: AsyncAPI 3.0 +version: 3.0 +versions: + - version: 3.0.0 + url: https://www.asyncapi.com/docs/reference/specification/v3.0.0 +prefix: AsyncApi30 +namespace: io.apicurio.datamodels.models.asyncapi.v30 + +traits: + - name: Extensible + properties: + - name: '/^x-.+$/' + type: any + collection: extensions + - name: Referenceable + properties: + - name: '$ref' + type: string + +entities: + - name: Document + root: true + traits: + - Extensible + properties: + - name: asyncapi + type: string + - name: id + type: string + - name: info + type: Info + - name: servers + type: Servers + - name: defaultContentType + type: string + - name: channels + type: Channels + - name: operations + type: Operations + - name: components + type: Components + propertyOrder: + - $this + - $Extensible + + - name: Info + traits: + - Extensible + properties: + - name: title + type: string + - name: version + type: string + - name: description + type: string + - name: termsOfService + type: string + - name: contact + type: Contact + - name: license + type: License + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + propertyOrder: + - $this + - $Extensible + + - name: Contact + traits: + - Extensible + properties: + - name: name + type: string + - name: url + type: string + - name: email + type: string + propertyOrder: + - $this + - $Extensible + + - name: License + traits: + - Extensible + properties: + - name: name + type: string + - name: url + type: string + propertyOrder: + - $this + - $Extensible + + - name: Servers + properties: + - name: '*' + type: Server + propertyOrder: + - $this + + - name: Server + traits: + - Extensible + - Referenceable + properties: + - name: host + type: string + - name: protocol + type: string + - name: protocolVersion + type: string + - name: pathname + type: string + - name: description + type: string + - name: title + type: string + - name: summary + type: string + - name: variables + type: '{ServerVariable}' + - name: security + type: '[SecurityScheme]' + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: ServerBindings + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: ServerVariable + traits: + - Extensible + - Referenceable + properties: + - name: enum + type: '[string]' + - name: default + type: string + - name: description + type: string + - name: examples + type: '[string]' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Channels + properties: + - name: '*' + type: Channel + propertyOrder: + - $this + + - name: Channel + traits: + - Extensible + - Referenceable + properties: + - name: address + type: string + - name: messages + type: '{Message}' + - name: title + type: string + - name: summary + type: string + - name: description + type: string + - name: servers + type: '[Reference]' + - name: parameters + type: Parameters + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: ChannelBindings + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Operations + properties: + - name: '*' + type: Operation + propertyOrder: + - $this + + - name: Operation + traits: + - Extensible + - Referenceable + properties: + - name: action + type: string + - name: channel + type: Reference + - name: title + type: string + - name: summary + type: string + - name: description + type: string + - name: security + type: '[SecurityScheme]' + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: OperationBindings + - name: traits + type: '[OperationTrait]' + - name: messages + type: '[Reference]' + - name: reply + type: OperationReply + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: OperationTrait + traits: + - Extensible + - Referenceable + properties: + - name: title + type: string + - name: summary + type: string + - name: description + type: string + - name: security + type: '[SecurityScheme]' + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: OperationBindings + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: OperationReply + traits: + - Extensible + - Referenceable + properties: + - name: address + type: OperationReplyAddress + - name: channel + type: Reference + - name: messages + type: '[Reference]' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: OperationReplyAddress + traits: + - Extensible + - Referenceable + properties: + - name: description + type: string + - name: location + type: string + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Parameters + properties: + - name: '*' + type: Parameter + collection: items + propertyOrder: + - $this + + - name: Parameter + traits: + - Extensible + - Referenceable + properties: + - name: enum + type: '[string]' + - name: default + type: string + - name: description + type: string + - name: examples + type: '[string]' + - name: location + type: string + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: ServerBindings + traits: + - Extensible + - Referenceable + properties: + - name: http + type: Binding + - name: ws + type: Binding + - name: kafka + type: Binding + - name: anypointmq + type: Binding + - name: amqp + type: Binding + - name: amqp1 + type: Binding + - name: mqtt + type: Binding + - name: mqtt5 + type: Binding + - name: nats + type: Binding + - name: jms + type: Binding + - name: sns + type: Binding + - name: solace + type: Binding + - name: sqs + type: Binding + - name: stomp + type: Binding + - name: redis + type: Binding + - name: mercure + type: Binding + - name: ibmmq + type: Binding + - name: googlepubsub + type: Binding + - name: pulsar + type: Binding + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: ChannelBindings + traits: + - Extensible + - Referenceable + properties: + - name: http + type: Binding + - name: ws + type: Binding + - name: kafka + type: Binding + - name: anypointmq + type: Binding + - name: amqp + type: Binding + - name: amqp1 + type: Binding + - name: mqtt + type: Binding + - name: mqtt5 + type: Binding + - name: nats + type: Binding + - name: jms + type: Binding + - name: sns + type: Binding + - name: solace + type: Binding + - name: sqs + type: Binding + - name: stomp + type: Binding + - name: redis + type: Binding + - name: mercure + type: Binding + - name: ibmmq + type: Binding + - name: googlepubsub + type: Binding + - name: pulsar + type: Binding + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: OperationBindings + traits: + - Extensible + - Referenceable + properties: + - name: http + type: Binding + - name: ws + type: Binding + - name: kafka + type: Binding + - name: anypointmq + type: Binding + - name: amqp + type: Binding + - name: amqp1 + type: Binding + - name: mqtt + type: Binding + - name: mqtt5 + type: Binding + - name: nats + type: Binding + - name: jms + type: Binding + - name: sns + type: Binding + - name: solace + type: Binding + - name: sqs + type: Binding + - name: stomp + type: Binding + - name: redis + type: Binding + - name: mercure + type: Binding + - name: ibmmq + type: Binding + - name: googlepubsub + type: Binding + - name: pulsar + type: Binding + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: MessageBindings + traits: + - Extensible + - Referenceable + properties: + - name: http + type: Binding + - name: ws + type: Binding + - name: kafka + type: Binding + - name: anypointmq + type: Binding + - name: amqp + type: Binding + - name: amqp1 + type: Binding + - name: mqtt + type: Binding + - name: mqtt5 + type: Binding + - name: nats + type: Binding + - name: jms + type: Binding + - name: sns + type: Binding + - name: solace + type: Binding + - name: sqs + type: Binding + - name: stomp + type: Binding + - name: redis + type: Binding + - name: mercure + type: Binding + - name: ibmmq + type: Binding + - name: googlepubsub + type: Binding + - name: pulsar + type: Binding + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Message + traits: + - Extensible + - Referenceable + properties: + - name: headers + type: 'MultiFormatSchema|Schema' + unionRules: + - unionType: 'MultiFormatSchema' + ruleType: propertyExists + propertyName: schemaFormat + - name: payload + type: 'MultiFormatSchema|Schema' + unionRules: + - unionType: 'MultiFormatSchema' + ruleType: propertyExists + propertyName: schemaFormat + - name: correlationId + type: CorrelationID + - name: contentType + type: string + - name: name + type: string + - name: title + type: string + - name: summary + type: string + - name: description + type: string + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: MessageBindings + - name: examples + type: '[MessageExample]' + - name: traits + type: '[MessageTrait]' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: MessageTrait + traits: + - Extensible + - Referenceable + properties: + - name: headers + type: 'MultiFormatSchema|Schema' + unionRules: + - unionType: 'MultiFormatSchema' + ruleType: propertyExists + propertyName: schemaFormat + - name: correlationId + type: CorrelationID + - name: contentType + type: string + - name: name + type: string + - name: title + type: string + - name: summary + type: string + - name: description + type: string + - name: tags + type: '[Tag]' + - name: externalDocs + type: ExternalDocumentation + - name: bindings + type: MessageBindings + - name: examples + type: '[MessageExample]' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: MessageExample + traits: + - Extensible + properties: + - name: headers + type: '{any}' + - name: payload + type: '{any}' + - name: name + type: string + - name: summary + type: string + propertyOrder: + - $this + - $Extensible + + - name: Tag + traits: + - Extensible + - Referenceable + properties: + - name: name + type: string + - name: description + type: string + - name: externalDocs + type: ExternalDocumentation + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: ExternalDocumentation + traits: + - Extensible + - Referenceable + properties: + - name: description + type: string + - name: url + type: string + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Reference + traits: + - Referenceable + properties: + - name: '$ref' + type: string + propertyOrder: + - $Referenceable + + - name: Components + traits: + - Extensible + properties: + - name: schemas + type: '{Schema}' + - name: servers + type: '{Server}' + - name: channels + type: '{Channel}' + - name: operations + type: '{Operation}' + - name: messages + type: '{Message}' + - name: securitySchemes + type: '{SecurityScheme}' + - name: serverVariables + type: '{ServerVariable}' + - name: parameters + type: '{Parameter}' + - name: correlationIds + type: '{CorrelationID}' + - name: replies + type: '{OperationReply}' + - name: replyAddresses + type: '{OperationReplyAddress}' + - name: externalDocs + type: '{ExternalDocumentation}' + - name: tags + type: '{Tag}' + - name: operationTraits + type: '{OperationTrait}' + - name: messageTraits + type: '{MessageTrait}' + - name: serverBindings + type: '{ServerBindings}' + - name: channelBindings + type: '{ChannelBindings}' + - name: operationBindings + type: '{OperationBindings}' + - name: messageBindings + type: '{MessageBindings}' + propertyOrder: + - $this + - $Extensible + + - name: MultiFormatSchema + traits: + - Extensible + - Referenceable + properties: + - name: schemaFormat + type: string + - name: schema + type: 'Schema|any' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Schema + traits: + - Extensible + - Referenceable + properties: + - name: title + type: string + - name: type + type: string + - name: required + type: '[string]' + - name: multipleOf + type: number + - name: maximum + type: number + - name: exclusiveMaximum + type: number + - name: minimum + type: number + - name: exclusiveMinimum + type: number + - name: maxLength + type: integer + - name: minLength + type: integer + - name: pattern + type: string + - name: maxItems + type: integer + - name: minItems + type: integer + - name: uniqueItems + type: boolean + - name: maxProperties + type: integer + - name: minProperties + type: integer + - name: enum + type: '[any]' + - name: const + type: any + - name: examples + type: '[any]' + - name: if + type: Schema + - name: then + type: Schema + - name: else + type: Schema + - name: readOnly + type: boolean + - name: writeOnly + type: boolean + - name: properties + type: '{Schema}' + - name: patternProperties + type: '{string}' + - name: additionalProperties + type: 'boolean|Schema' + - name: additionalItems + type: Schema + - name: items + type: 'Schema|[Schema]' + - name: propertyNames + type: Schema + - name: contains + type: Schema + - name: allOf + type: '[Schema]' + - name: oneOf + type: '[Schema]' + - name: anyOf + type: '[Schema]' + - name: not + type: Schema + - name: description + type: string + - name: format + type: string + - name: default + type: any + - name: discriminator + type: string + - name: externalDocs + type: ExternalDocumentation + - name: deprecated + type: boolean + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: SecurityScheme + traits: + - Extensible + - Referenceable + properties: + - name: type + type: string + - name: description + type: string + - name: name + type: string + - name: in + type: string + - name: scheme + type: string + - name: bearerFormat + type: string + - name: flows + type: OAuthFlows + - name: openIdConnectUrl + type: string + - name: scopes + type: '[string]' + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: OAuthFlows + traits: + - Extensible + properties: + - name: implicit + type: OAuthFlow + - name: password + type: OAuthFlow + - name: clientCredentials + type: OAuthFlow + - name: authorizationCode + type: OAuthFlow + propertyOrder: + - $this + - $Extensible + + - name: OAuthFlow + traits: + - Extensible + properties: + - name: authorizationUrl + type: string + - name: tokenUrl + type: string + - name: refreshUrl + type: string + - name: availableScopes + type: '{string}' + propertyOrder: + - $this + - $Extensible + + - name: CorrelationID + traits: + - Extensible + - Referenceable + properties: + - name: description + type: string + - name: location + type: string + propertyOrder: + - $Referenceable + - $this + - $Extensible + + - name: Binding + traits: + - Extensible + properties: + - name: '*' + type: any + propertyOrder: + - $this + - $Extensible diff --git a/src/main/ts/src/io/apicurio/datamodels/models/util/JsonUtil.ts b/src/main/ts/src/io/apicurio/datamodels/models/util/JsonUtil.ts index 719299dc..953ee4e7 100755 --- a/src/main/ts/src/io/apicurio/datamodels/models/util/JsonUtil.ts +++ b/src/main/ts/src/io/apicurio/datamodels/models/util/JsonUtil.ts @@ -434,10 +434,32 @@ export class JsonUtil { return typeof value === "string"; } + public static isJsonNode(value: any): boolean { + if (value == null) { + return false; + } + return true; + } + + public static isObjectNode(value: any): boolean { + if (value == null) { + return false; + } + return typeof value === "object"; + } + public static toString(value: any): string { return value; } + public static toJsonNode(value: any): any { + return value; + } + + public static toObjectNode(value: any): object { + return value; + } + public static isBoolean(value: any): boolean { if (value == null) { return false; diff --git a/src/test/java/io/apicurio/datamodels/io/IoTestRunner.java b/src/test/java/io/apicurio/datamodels/io/IoTestRunner.java index f6d9fec2..51097ff5 100755 --- a/src/test/java/io/apicurio/datamodels/io/IoTestRunner.java +++ b/src/test/java/io/apicurio/datamodels/io/IoTestRunner.java @@ -114,6 +114,11 @@ public void evaluate() throws Throwable { Library.visitTree(doc, epv, TraverserDirection.down); int actualExtraProps = epv.getExtraPropertyCount(); int expectedExtraProps = child.getExtraProperties(); + if (actualExtraProps != expectedExtraProps) { + epv.extraProperties.forEach(ep -> { + System.out.println("DETECTED EXTRA PROPERTY: " + ep); + }); + } Assert.assertEquals("Wrong number of extra properties found: " + epv.extraProperties, expectedExtraProps, actualExtraProps); // Write the data model back to JSON diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/adeo-kafka-request-reply-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/adeo-kafka-request-reply-asyncapi.json new file mode 100644 index 00000000..67fdcfdd --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/adeo-kafka-request-reply-asyncapi.json @@ -0,0 +1,353 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Adeo AsyncAPI Case Study", + "version": "%REPLACED_BY_MAVEN%", + "description": "This Adeo specification illustrates how ADEO uses AsyncAPI to document some of their exchanges.\n", + "contact": { + "name": "AsyncAPI Community", + "email": "case-study@asyncapi.com" + }, + "tags": [ + { + "name": "costing", + "description": "Costing channels, used by Costing clients." + } + ] + }, + "servers": { + "production": { + "host": "prod.url:9092", + "protocol": "kafka", + "description": "Kafka PRODUCTION cluster", + "security": [ + { + "$ref": "#/components/securitySchemes/sasl-ssl" + } + ], + "bindings": { + "kafka": { + "schemaRegistryUrl": "https://schema-registry.prod.url/" + } + } + }, + "staging": { + "host": "staging.url:9092", + "protocol": "kafka", + "description": "Kafka STAGING cluster for `uat` and `preprod` environments", + "security": [ + { + "$ref": "#/components/securitySchemes/sasl-ssl" + } + ], + "bindings": { + "kafka": { + "schemaRegistryUrl": "https://schema-registry.prod.url/" + } + } + }, + "dev": { + "host": "dev.url:9092", + "protocol": "kafka", + "description": "Kafka DEV cluster for `dev` and `sit` environments", + "security": [ + { + "$ref": "#/components/securitySchemes/sasl-ssl" + } + ], + "bindings": { + "kafka": { + "schemaRegistryUrl": "https://schema-registry.prod.url/" + } + } + } + }, + "channels": { + "costingRequestChannel": { + "address": "adeo-{env}-case-study-COSTING-REQUEST-{version}", + "description": "Use this topic to do a Costing Request to Costing product. We use the [**RecordNameStrategy**](https://docs.confluent.io/platform/current/schema-registry/serdes-develop/index.html#subject-name-strategy) to infer the messages schema. You have to define `value.subject.name.strategy` to `io.confluent.kafka.serializers.subject.RecordNameStrategy` in your producer to use the schema we manage. The schema below illustrates how Costing Request messages are handled. ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png)\n", + "parameters": { + "env": { + "$ref": "#/components/parameters/Env" + }, + "version": { + "$ref": "#/components/parameters/Version" + } + }, + "bindings": { + "kafka": { + "replicas": 3, + "partitions": 3, + "topicConfiguration": { + "cleanup.policy": [ + "delete" + ], + "retention.ms": 60000000 + } + } + }, + "messages": { + "CostingRequest": { + "$ref": "#/components/messages/costingRequestV1" + } + } + }, + "costingResponseChannel": { + "description": "This topic is used to REPLY Costing Requests and is targeted by the `REPLY_TOPIC` header. **You must grant PUBLISH access to our `svc-ccr-app` service account.**. We use the [**RecordNameStrategy**](https://docs.confluent.io/platform/current/schema-registry/serdes-develop/index.html#subject-name-strategy) to infer the messages schema. \nTopic should follow pattern \"adeo-{env}-case-study-COSTING-RESPONSE-{version}\"\nYou have to define `key.subject.name.strategy` and `value.subject.name.strategy` to `io.confluent.kafka.serializers.subject.RecordNameStrategy` in your consumer. The schema below illustrates how Costing Response messages are handled.\n ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png)\n", + "bindings": { + "kafka": { + "x-key.subject.name.strategy": { + "type": "string", + "description": "We use the RecordNameStrategy to infer the messages schema. Use `key.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` in your consumer configuration.\n" + }, + "x-value.subject.name.strategy": { + "type": "string", + "description": "We use the RecordNameStrategy to infer the messages schema. Use `value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` in your consumer configuration.\n" + } + } + }, + "tags": [ + { + "name": "costing" + } + ], + "messages": { + "costingResponse": { + "$ref": "#/components/messages/costingResponse" + } + } + } + }, + "operations": { + "receiveACostingRequest": { + "action": "receive", + "channel": { + "$ref": "#/channels/costingRequestChannel" + }, + "reply": { + "channel": { + "$ref": "#/channels/costingResponseChannel" + }, + "address": { + "location": "$message.header#/REPLY_TOPIC" + } + }, + "summary": "[COSTING] Request one or more Costing calculation for any product\n", + "description": "You can try a costing request using our [Conduktor producer template](https://conduktor.url/)\n", + "tags": [ + { + "name": "costing" + } + ], + "bindings": { + "kafka": { + "groupId": { + "type": "string", + "description": "The groupId must be prefixed by your `svc` account, deliver by the Adeo Kafka team. This `svc` must have the write access to the topic.\n" + }, + "x-value.subject.name.strategy": { + "type": "string", + "description": "We use the RecordNameStrategy to infer the messages schema. Use `value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` in your producer configuration.\n" + } + } + } + } + }, + "components": { + "correlationIds": { + "costingCorrelationId": { + "description": "This correlation ID is used for message tracing and messages correlation. This correlation ID is generated at runtime based on the `REQUEST_ID` and sent to the RESPONSE message.\n", + "location": "$message.header#/REQUEST_ID" + } + }, + "messages": { + "costingRequestV1": { + "name": "CostingRequestV1", + "title": "Costing Request V1", + "summary": "Costing Request V1 inputs.", + "tags": [ + { + "name": "costing" + } + ], + "correlationId": { + "$ref": "#/components/correlationIds/costingCorrelationId" + }, + "headers": { + "type": "object", + "required": [ + "REQUESTER_ID", + "REQUESTER_CODE", + "REQUEST_ID", + "REPLY_TOPIC" + ], + "properties": { + "REQUEST_ID": { + "$ref": "#/components/schemas/RequestId" + }, + "REPLY_TOPIC": { + "$ref": "#/components/schemas/ReplyTopic" + }, + "REQUESTER_ID": { + "$ref": "#/components/schemas/RequesterId" + }, + "REQUESTER_CODE": { + "$ref": "#/components/schemas/RequesterCode" + } + } + }, + "payload": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "$ref": "https://www.asyncapi.com/resources/casestudies/adeo/CostingRequestPayload.avsc" + } + } + }, + "costingResponse": { + "name": "CostingResponse", + "title": "Costing Response", + "summary": "Costing Response ouputs.", + "tags": [ + { + "name": "costing" + } + ], + "description": "Please refer to the `CostingResponseKey.avsc` schema, available on [our github project](https://github.url/).\n", + "correlationId": { + "$ref": "#/components/correlationIds/costingCorrelationId" + }, + "headers": { + "type": "object", + "properties": { + "CALCULATION_ID": { + "$ref": "#/components/schemas/MessageId" + }, + "CORRELATION_ID": { + "$ref": "#/components/schemas/CorrelationId" + }, + "REQUEST_TIMESTAMP": { + "type": "string", + "format": "date-time", + "description": "Timestamp of the costing request" + }, + "CALCULATION_TIMESTAMP": { + "type": "string", + "format": "date-time", + "description": "Technical timestamp for the costing calculation" + } + } + }, + "payload": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "$ref": "https://www.asyncapi.com/resources/casestudies/adeo/CostingResponsePayload.avsc" + } + } + } + }, + "schemas": { + "RequesterId": { + "type": "string", + "description": "The Costing requester service account used to produce costing request.", + "examples": [ + "svc-ecollect-app" + ] + }, + "RequesterCode": { + "type": "string", + "description": "The Costing requester code (generally the BU Code). The requester code is useful to get the dedicated context (tenant).", + "examples": [ + 1 + ] + }, + "MessageId": { + "type": "string", + "format": "uuid", + "description": "A unique Message ID.", + "examples": [ + "1fa6ef40-8f47-40a8-8cf6-f8607d0066ef" + ] + }, + "RequestId": { + "type": "string", + "format": "uuid", + "description": "A unique Request ID needed to define a `CORRELATION_ID` for exchanges, which will be sent back in the Costing Responses.", + "examples": [ + "1fa6ef40-8f47-40a8-8cf6-f8607d0066ef" + ] + }, + "CorrelationId": { + "type": "string", + "format": "uuid", + "description": "A unique Correlation ID defined from the `REQUEST_ID` or the `MESSAGE_ID` provided in the Costing Request.", + "examples": [ + "1fa6ef40-8f47-40a8-8cf6-f8607d0066ef" + ] + }, + "BuCode": { + "type": "string", + "description": "The Business Unit code for which data are applicable.", + "examples": [ + 1 + ] + }, + "ReplyTopic": { + "type": "string", + "description": "The Kafka topic where to send the Costing Response. This is required for the [Return Address EIP pattern](https://www.enterpriseintegrationpatterns.com/patterns/messaging/ReturnAddress.html). **You must grant WRITE access to our `svc-ccr-app` service account.**\n", + "examples": [ + "adeo-case-study-COSTING-RESPONSE-V1" + ] + }, + "ErrorStep": { + "type": "string", + "description": "The woker that has thrown the error.\n", + "examples": [ + "EXPOSE_RESULT" + ] + }, + "ErrorMessage": { + "type": "string", + "description": "The error message describing the error.\n", + "examples": [ + "Error message" + ] + }, + "ErrorCode": { + "type": "string", + "description": "The error code.\n", + "examples": [ + "CURRENCY_NOT_FOUND" + ] + } + }, + "parameters": { + "Env": { + "description": "Adeo Kafka Environement for messages publications.", + "enum": [ + "dev", + "sit", + "uat1", + "preprod", + "prod" + ] + }, + "Version": { + "description": "the topic version you want to use", + "examples": [ + "V1" + ], + "default": "V1" + } + }, + "securitySchemes": { + "sasl-ssl": { + "type": "plain", + "x-sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\" password=\"\";", + "x-security.protocol": "SASL_SSL", + "x-ssl.endpoint.identification.algorithm": "https", + "x-sasl.mechanism": "PLAIN", + "description": "Use [SASL authentication with SSL encryption](https://docs.confluent.io/platform/current/security/security_tutorial.html#configure-clients) to connect to the ADEO Broker." + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/anyof-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/anyof-asyncapi.json new file mode 100644 index 00000000..ed42dd8f --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/anyof-asyncapi.json @@ -0,0 +1,65 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "AnyOf example", + "version": "1.0.0" + }, + "channels": { + "test": { + "address": "test", + "messages": { + "testMessages": { + "$ref": "#/components/messages/testMessages" + } + } + } + }, + "operations": { + "test": { + "action": "receive", + "channel": { + "$ref": "#/channels/test" + }, + "messages": [ + { + "$ref": "#/channels/test/messages/testMessages" + } + ] + } + }, + "components": { + "messages": { + "testMessages": { + "payload": { + "anyOf": [ + { + "$ref": "#/components/schemas/objectWithKey" + }, + { + "$ref": "#/components/schemas/objectWithKey2" + } + ] + } + } + }, + "schemas": { + "objectWithKey": { + "type": "object", + "properties": { + "key": { + "type": "string", + "additionalProperties": false + } + } + }, + "objectWithKey2": { + "type": "object", + "properties": { + "key2": { + "type": "string" + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/application-headers-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/application-headers-asyncapi.json new file mode 100644 index 00000000..4080eed8 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/application-headers-asyncapi.json @@ -0,0 +1,123 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Application Headers example", + "version": "1.0.0", + "description": "A cut of the Streetlights API to test application header changes supporting", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "defaultContentType": "application/json", + "servers": { + "production": { + "host": "test.mosquitto.org:{port}", + "protocol": "mqtt", + "description": "Test broker", + "variables": { + "port": { + "description": "Secure connection (TLS) is available through port 8883.", + "default": "1883", + "enum": [ + "1883", + "8883" + ] + } + } + } + }, + "channels": { + "lightingMeasured": { + "address": "smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured", + "messages": { + "lightMeasured": { + "$ref": "#/components/messages/lightMeasured" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + } + }, + "operations": { + "receiveLightMeasurement": { + "action": "receive", + "channel": { + "$ref": "#/channels/lightingMeasured" + }, + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "messages": [ + { + "$ref": "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + } + }, + "components": { + "messages": { + "lightMeasured": { + "name": "lightMeasured", + "title": "Light measured", + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "correlationId": { + "location": "$message.header#/MQMD/CorrelId" + }, + "contentType": "application/json", + "headers": { + "type": "object", + "properties": { + "MQMD": { + "type": "object", + "properties": { + "CorrelId": { + "type": "string", + "minLength": 24, + "maxLength": 24, + "format": "binary" + } + } + }, + "applicationInstanceId": { + "$ref": "#/components/schemas/applicationInstanceId" + } + } + }, + "payload": { + "$ref": "#/components/schemas/lightMeasuredPayload" + } + } + }, + "schemas": { + "lightMeasuredPayload": { + "type": "object", + "properties": { + "lumens": { + "type": "integer", + "minimum": 0, + "description": "Light intensity measured in lumens." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "sentAt": { + "type": "string", + "format": "date-time", + "description": "Date and time when the message was sent." + }, + "applicationInstanceId": { + "description": "Unique identifier for a given instance of the publishing application", + "type": "string" + } + }, + "parameters": { + "streetlightId": { + "description": "The ID of the streetlight." + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/correlation-id-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/correlation-id-asyncapi.json new file mode 100644 index 00000000..e6962efd --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/correlation-id-asyncapi.json @@ -0,0 +1,259 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Correlation ID Example", + "version": "1.0.0", + "description": "A cut of the Streetlights API to test Correlation ID", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "defaultContentType": "application/json", + "servers": { + "production": { + "host": "test.mosquitto.org:{port}", + "protocol": "mqtt", + "description": "Test broker", + "variables": { + "port": { + "description": "Secure connection (TLS) is available through port 8883.", + "default": "1883", + "enum": [ + "1883", + "8883" + ] + } + }, + "security": [ + { + "$ref": "#/components/securitySchemes/apiKey" + }, + { + "type": "oauth2", + "description": "Flows to support OAuth 2.0", + "flows": { + "implicit": { + "authorizationUrl": "https://authserver.example/auth", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "password": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "clientCredentials": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "authorizationCode": { + "authorizationUrl": "https://authserver.example/auth", + "tokenUrl": "https://authserver.example/token", + "refreshUrl": "https://authserver.example/refresh", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + } + }, + "scopes": [ + "streetlights:on", + "streetlights:off", + "streetlights:dim" + ] + }, + { + "$ref": "#/components/securitySchemes/openIdConnectWellKnown" + } + ] + } + }, + "channels": { + "lightingMeasured": { + "address": "smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured", + "messages": { + "lightMeasured": { + "$ref": "#/components/messages/lightMeasured" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightsDim": { + "address": "smartylighting/streetlights/1/0/action/{streetlightId}/dim", + "messages": { + "dimLight": { + "$ref": "#/components/messages/dimLight" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + } + }, + "operations": { + "receiveLightMeasurement": { + "action": "receive", + "channel": { + "$ref": "#/channels/lightingMeasured" + }, + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "messages": [ + { + "$ref": "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + }, + "dimLight": { + "action": "send", + "channel": { + "$ref": "#/channels/lightsDim" + }, + "messages": [ + { + "$ref": "#/channels/lightsDim/messages/dimLight" + } + ] + } + }, + "components": { + "messages": { + "lightMeasured": { + "name": "lightMeasured", + "title": "Light measured", + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "correlationId": { + "location": "$message.header#/MQMD/CorrelId" + }, + "contentType": "application/json", + "payload": { + "$ref": "#/components/schemas/lightMeasuredPayload" + } + }, + "dimLight": { + "name": "dimLight", + "title": "Dim light", + "summary": "Command a particular streetlight to dim the lights.", + "correlationId": { + "$ref": "#/components/correlationIds/sentAtCorrelator" + }, + "payload": { + "$ref": "#/components/schemas/dimLightPayload" + } + } + }, + "schemas": { + "lightMeasuredPayload": { + "type": "object", + "properties": { + "lumens": { + "type": "integer", + "minimum": 0, + "description": "Light intensity measured in lumens." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "dimLightPayload": { + "type": "object", + "properties": { + "percentage": { + "type": "integer", + "description": "Percentage to which the light should be dimmed to.", + "minimum": 0, + "maximum": 100 + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "sentAt": { + "type": "string", + "format": "date-time", + "description": "Date and time when the message was sent." + } + }, + "parameters": { + "streetlightId": { + "description": "The ID of the streetlight." + } + }, + "correlationIds": { + "sentAtCorrelator": { + "description": "Data from message payload used as correlation ID", + "location": "$message.payload#/sentAt" + } + }, + "securitySchemes": { + "apiKey": { + "type": "apiKey", + "in": "user", + "description": "Provide your API key as the user and leave the password empty." + }, + "supportedOauthFlows": { + "type": "oauth2", + "description": "Flows to support OAuth 2.0", + "flows": { + "implicit": { + "authorizationUrl": "https://authserver.example/auth", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "password": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "clientCredentials": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "authorizationCode": { + "authorizationUrl": "https://authserver.example/auth", + "tokenUrl": "https://authserver.example/token", + "refreshUrl": "https://authserver.example/refresh", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + } + } + }, + "openIdConnectWellKnown": { + "type": "openIdConnect", + "openIdConnectUrl": "https://authserver.example/.well-known" + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/gitter-streaming-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/gitter-streaming-asyncapi.json new file mode 100644 index 00000000..f2e3e8b0 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/gitter-streaming-asyncapi.json @@ -0,0 +1,261 @@ +{ + "asyncapi": "3.0.0", + "id": "tag:stream.gitter.im,2022:api", + "info": { + "title": "Gitter Streaming API", + "version": "1.0.0" + }, + "servers": { + "production": { + "host": "stream.gitter.im", + "pathname": "/v1", + "protocol": "https", + "protocolVersion": "1.1", + "security": [ + { + "$ref": "#/components/securitySchemes/httpBearerToken" + } + ] + } + }, + "channels": { + "rooms": { + "address": "/rooms/{roomId}/{resource}", + "messages": { + "chatMessage": { + "$ref": "#/components/messages/chatMessage" + }, + "heartbeat": { + "$ref": "#/components/messages/heartbeat" + } + }, + "parameters": { + "roomId": { + "description": "Id of the Gitter room.", + "examples": [ + "53307860c3599d1de448e19d" + ] + }, + "resource": { + "enum": [ + "chatMessages", + "events" + ], + "description": "The resource to consume." + } + } + } + }, + "operations": { + "sendRoomInfo": { + "action": "send", + "channel": { + "$ref": "#/channels/rooms" + }, + "bindings": { + "http": { + "method": "POST" + } + }, + "messages": [ + { + "$ref": "#/channels/rooms/messages/chatMessage" + }, + { + "$ref": "#/channels/rooms/messages/heartbeat" + } + ] + } + }, + "components": { + "securitySchemes": { + "httpBearerToken": { + "type": "http", + "scheme": "bearer" + } + }, + "messages": { + "chatMessage": { + "summary": "A message represents an individual chat message sent to a room. They are a sub-resource of a room.", + "payload": { + "schemaFormat": "application/schema+yaml;version=draft-07", + "schema": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "ID of the message." + }, + "text": { + "type": "string", + "description": "Original message in plain-text/markdown." + }, + "html": { + "type": "string", + "description": "HTML formatted message." + }, + "sent": { + "type": "string", + "format": "date-time", + "description": "ISO formatted date of the message." + }, + "fromUser": { + "type": "object", + "description": "User that sent the message.", + "properties": { + "id": { + "type": "string", + "description": "Gitter User ID." + }, + "username": { + "type": "string", + "description": "Gitter/GitHub username." + }, + "displayName": { + "type": "string", + "description": "Gitter/GitHub user real name." + }, + "url": { + "type": "string", + "description": "Path to the user on Gitter." + }, + "avatarUrl": { + "type": "string", + "format": "uri", + "description": "User avatar URI." + }, + "avatarUrlSmall": { + "type": "string", + "format": "uri", + "description": "User avatar URI (small)." + }, + "avatarUrlMedium": { + "type": "string", + "format": "uri", + "description": "User avatar URI (medium)." + }, + "v": { + "type": "number", + "description": "Version." + }, + "gv": { + "type": "string", + "description": "Stands for \"Gravatar version\" and is used for cache busting." + } + } + }, + "unread": { + "type": "boolean", + "description": "Boolean that indicates if the current user has read the message." + }, + "readBy": { + "type": "number", + "description": "Number of users that have read the message." + }, + "urls": { + "type": "array", + "description": "List of URLs present in the message.", + "items": { + "type": "string", + "format": "uri" + } + }, + "mentions": { + "type": "array", + "description": "List of @Mentions in the message.", + "items": { + "type": "object", + "properties": { + "screenName": { + "type": "string" + }, + "userId": { + "type": "string" + }, + "userIds": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "issues": { + "type": "array", + "description": "List of #Issues referenced in the message.", + "items": { + "type": "object", + "properties": { + "number": { + "type": "string" + } + } + } + }, + "meta": { + "type": "array", + "description": "Metadata. This is currently not used for anything.", + "items": {} + }, + "v": { + "type": "number", + "description": "Version." + }, + "gv": { + "type": "string", + "description": "Stands for \"Gravatar version\" and is used for cache busting." + } + } + } + }, + "bindings": { + "http": { + "headers": { + "type": "object", + "properties": { + "Transfer-Encoding": { + "type": "string", + "const": "chunked" + }, + "Trailer": { + "type": "string", + "const": "\\r\\n" + } + } + } + } + } + }, + "heartbeat": { + "summary": "Its purpose is to keep the connection alive.", + "payload": { + "schemaFormat": "application/schema+yaml;version=draft-07", + "schema": { + "type": "string", + "enum": [ + "\r\n" + ] + } + }, + "bindings": { + "http": { + "headers": { + "type": "object", + "properties": { + "Transfer-Encoding": { + "type": "string", + "const": "chunked" + }, + "Trailer": { + "type": "string", + "const": "\\r\\n" + } + } + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-message-filter-in-reply-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-message-filter-in-reply-asyncapi.json new file mode 100644 index 00000000..35e364c1 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-message-filter-in-reply-asyncapi.json @@ -0,0 +1,558 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Kraken Websockets API", + "version": "1.8.0", + "description": "WebSockets API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The public message types presented below do not require authentication. Private-data messages can be subscribed on a separate authenticated endpoint. \n\n### General Considerations\n\n- TLS with SNI (Server Name Indication) is required in order to establish a Kraken WebSockets API connection. See Cloudflare's [What is SNI?](https://www.cloudflare.com/learning/ssl/what-is-sni/) guide for more details.\n- All messages sent and received via WebSockets are encoded in JSON format\n- All decimal fields (including timestamps) are quoted to preserve precision.\n- Timestamps should not be considered unique and not be considered as aliases for transaction IDs. Also, the granularity of timestamps is not representative of transaction rates.\n- At least one private message should be subscribed to keep the authenticated client connection open.\n- Please use REST API endpoint [AssetPairs](https://www.kraken.com/features/api#get-tradable-pairs) to fetch the list of pairs which can be subscribed via WebSockets API. For example, field 'wsname' gives the supported pairs name which can be used to subscribe.\n- Cloudflare imposes a connection/re-connection rate limit (per IP address) of approximately 150 attempts per rolling 10 minutes. If this is exceeded, the IP is banned for 10 minutes.\n- Recommended reconnection behaviour is to (1) attempt reconnection instantly up to a handful of times if the websocket is dropped randomly during normal operation but (2) after maintenance or extended downtime, attempt to reconnect no more quickly than once every 5 seconds. There is no advantage to reconnecting more rapidly after maintenance during cancel_only mode.\n" + }, + "channels": { + "currencyExchange": { + "address": "/", + "messages": { + "ping": { + "$ref": "#/components/messages/ping" + }, + "pong": { + "$ref": "#/components/messages/pong" + }, + "heartbeat": { + "$ref": "#/components/messages/heartbeat" + }, + "systemStatus": { + "$ref": "#/components/messages/systemStatus" + }, + "subscriptionStatus": { + "$ref": "#/components/messages/subscriptionStatus" + }, + "subscribe": { + "$ref": "#/components/messages/subscribe" + }, + "unsubscribe": { + "$ref": "#/components/messages/unsubscribe" + }, + "dummyCurrencyInfo": { + "$ref": "#/components/messages/dummyCurrencyInfo" + } + } + } + }, + "operations": { + "receivePing": { + "action": "receive", + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "reply": { + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/pong" + } + ] + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/ping" + } + ] + }, + "sendHeartbeat": { + "action": "send", + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/heartbeat" + } + ] + }, + "systemStatus": { + "action": "send", + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/systemStatus" + } + ] + }, + "receiveSubscribeRequest": { + "action": "receive", + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "reply": { + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/subscriptionStatus" + }, + { + "$ref": "#/channels/currencyExchange/messages/dummyCurrencyInfo" + } + ] + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/subscribe" + } + ] + }, + "receiveUnsubscribeRequest": { + "action": "receive", + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "reply": { + "channel": { + "$ref": "#/channels/currencyExchange" + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/subscriptionStatus" + } + ] + }, + "messages": [ + { + "$ref": "#/channels/currencyExchange/messages/unsubscribe" + } + ] + } + }, + "components": { + "messages": { + "dummyCurrencyInfo": { + "summary": "Dummy message with no real life details", + "description": "It is here in this example to showcase that there is an additional message that normally is of a complex structure. It represents actually currency exchange value to show a reply to operation receiveSubscribeRequest with more than one possible message.", + "payload": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "currencyInfo" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "data": { + "type": "object" + } + }, + "required": [ + "event" + ] + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "ping": { + "summary": "Ping server to determine whether connection is alive", + "description": "Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated", + "payload": { + "$ref": "#/components/schemas/ping" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "pong": { + "summary": "Pong is a response to ping message", + "description": "Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in websockets standard which is sent by client in response to a ping", + "payload": { + "$ref": "#/components/schemas/pong" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "subscribe": { + "description": "Subscribe to a topic on a single or multiple currency pairs.", + "payload": { + "$ref": "#/components/schemas/subscribe" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "unsubscribe": { + "description": "Unsubscribe, can specify a channelID or multiple currency pairs.", + "payload": { + "$ref": "#/components/schemas/unsubscribe" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "subscriptionStatus": { + "description": "Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.", + "payload": { + "$ref": "#/components/schemas/subscriptionStatus" + }, + "examples": [ + { + "payload": { + "channelID": 10001, + "channelName": "ohlc-5", + "event": "subscriptionStatus", + "pair": "XBT/EUR", + "reqid": 42, + "status": "unsubscribed", + "subscription": { + "interval": 5, + "name": "ohlc" + } + } + }, + { + "payload": { + "errorMessage": "Subscription depth not supported", + "event": "subscriptionStatus", + "pair": "XBT/USD", + "status": "error", + "subscription": { + "depth": 42, + "name": "book" + } + } + } + ] + }, + "systemStatus": { + "description": "Status sent on connection or system status changes.", + "payload": { + "$ref": "#/components/schemas/systemStatus" + } + }, + "heartbeat": { + "description": "Server heartbeat sent if no subscription traffic within 1 second (approximately)", + "payload": { + "$ref": "#/components/schemas/heartbeat" + } + } + }, + "schemas": { + "ping": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "ping" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + } + }, + "required": [ + "event" + ] + }, + "heartbeat": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "heartbeat" + } + } + }, + "pong": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "pong" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + } + } + }, + "systemStatus": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "systemStatus" + }, + "connectionID": { + "type": "integer", + "description": "The ID of the connection" + }, + "status": { + "$ref": "#/components/schemas/status" + }, + "version": { + "type": "string" + } + } + }, + "status": { + "type": "string", + "enum": [ + "online", + "maintenance", + "cancel_only", + "limit_only", + "post_only" + ] + }, + "subscribe": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "subscribe" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "subscription": { + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "ratecounter": { + "$ref": "#/components/schemas/ratecounter" + }, + "snapshot": { + "$ref": "#/components/schemas/snapshot" + }, + "token": { + "$ref": "#/components/schemas/token" + } + }, + "required": [ + "name" + ] + } + }, + "required": [ + "event" + ] + }, + "unsubscribe": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "unsubscribe" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "subscription": { + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "token": { + "$ref": "#/components/schemas/token" + } + }, + "required": [ + "name" + ] + } + }, + "required": [ + "event" + ] + }, + "subscriptionStatus": { + "type": "object", + "oneOf": [ + { + "$ref": "#/components/schemas/subscriptionStatusError" + }, + { + "$ref": "#/components/schemas/subscriptionStatusSuccess" + } + ] + }, + "subscriptionStatusError": { + "allOf": [ + { + "properties": { + "errorMessage": { + "type": "string" + } + }, + "required": [ + "errorMessage" + ] + }, + { + "$ref": "#/components/schemas/subscriptionStatusCommon" + } + ] + }, + "subscriptionStatusSuccess": { + "allOf": [ + { + "properties": { + "channelID": { + "type": "integer", + "description": "ChannelID on successful subscription, applicable to public messages only." + }, + "channelName": { + "type": "string", + "description": "Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix." + } + }, + "required": [ + "channelID", + "channelName" + ] + }, + { + "$ref": "#/components/schemas/subscriptionStatusCommon" + } + ] + }, + "subscriptionStatusCommon": { + "type": "object", + "required": [ + "event" + ], + "properties": { + "event": { + "type": "string", + "const": "subscriptionStatus" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "status": { + "$ref": "#/components/schemas/status" + }, + "subscription": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "maxratecount": { + "$ref": "#/components/schemas/maxratecount" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "token": { + "$ref": "#/components/schemas/token" + } + } + } + } + }, + "interval": { + "type": "integer", + "description": "Time interval associated with ohlc subscription in minutes.", + "default": 1, + "enum": [ + 1, + 5, + 15, + 30, + 60, + 240, + 1440, + 10080, + 21600 + ] + }, + "name": { + "type": "string", + "description": "The name of the channel you subscribe too.", + "enum": [ + "book", + "ohlc", + "openOrders", + "ownTrades", + "spread", + "ticker", + "trade" + ] + }, + "token": { + "type": "string", + "description": "base64-encoded authentication token for private-data endpoints." + }, + "depth": { + "type": "integer", + "default": 10, + "enum": [ + 10, + 25, + 100, + 500, + 1000 + ], + "description": "Depth associated with book subscription in number of levels each side." + }, + "maxratecount": { + "type": "integer", + "description": "Max rate-limit budget. Compare to the ratecounter field in the openOrders updates to check whether you are approaching the rate limit." + }, + "ratecounter": { + "type": "boolean", + "default": false, + "description": "Whether to send rate-limit counter in updates (supported only for openOrders subscriptions)" + }, + "snapshot": { + "type": "boolean", + "default": true, + "description": "Whether to send historical feed data snapshot upon subscription (supported only for ownTrades subscriptions)" + }, + "reqid": { + "type": "integer", + "description": "client originated ID reflected in response message." + }, + "pair": { + "type": "array", + "description": "Array of currency pairs.", + "items": { + "type": "string", + "description": "Format of each pair is \"A/B\", where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized.", + "pattern": "[A-Z\\s]+\\/[A-Z\\s]+" + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-multiple-channels-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-multiple-channels-asyncapi.json new file mode 100644 index 00000000..4403b9c8 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/kraken-websocket-request-reply-multiple-channels-asyncapi.json @@ -0,0 +1,550 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Kraken Websockets API", + "version": "1.8.0", + "description": "WebSockets API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The public message types presented below do not require authentication. Private-data messages can be subscribed on a separate authenticated endpoint. \n\n### General Considerations\n\n- TLS with SNI (Server Name Indication) is required in order to establish a Kraken WebSockets API connection. See Cloudflare's [What is SNI?](https://www.cloudflare.com/learning/ssl/what-is-sni/) guide for more details.\n- All messages sent and received via WebSockets are encoded in JSON format\n- All decimal fields (including timestamps) are quoted to preserve precision.\n- Timestamps should not be considered unique and not be considered as aliases for transaction IDs. Also, the granularity of timestamps is not representative of transaction rates.\n- At least one private message should be subscribed to keep the authenticated client connection open.\n- Please use REST API endpoint [AssetPairs](https://www.kraken.com/features/api#get-tradable-pairs) to fetch the list of pairs which can be subscribed via WebSockets API. For example, field 'wsname' gives the supported pairs name which can be used to subscribe.\n- Cloudflare imposes a connection/re-connection rate limit (per IP address) of approximately 150 attempts per rolling 10 minutes. If this is exceeded, the IP is banned for 10 minutes.\n- Recommended reconnection behaviour is to (1) attempt reconnection instantly up to a handful of times if the websocket is dropped randomly during normal operation but (2) after maintenance or extended downtime, attempt to reconnect no more quickly than once every 5 seconds. There is no advantage to reconnecting more rapidly after maintenance during cancel_only mode.\n" + }, + "channels": { + "ping": { + "address": "/", + "messages": { + "ping": { + "$ref": "#/components/messages/ping" + } + } + }, + "pong": { + "address": "/", + "messages": { + "pong": { + "$ref": "#/components/messages/pong" + } + } + }, + "heartbeat": { + "address": "/", + "messages": { + "heartbeat": { + "$ref": "#/components/messages/heartbeat" + } + } + }, + "systemStatus": { + "address": "/", + "messages": { + "systemStatus": { + "$ref": "#/components/messages/systemStatus" + } + } + }, + "currencyInfo": { + "address": "/", + "messages": { + "subscriptionStatus": { + "$ref": "#/components/messages/subscriptionStatus" + }, + "dummyCurrencyInfo": { + "$ref": "#/components/messages/dummyCurrencyInfo" + } + } + }, + "subscribe": { + "address": "/", + "messages": { + "subscribe": { + "$ref": "#/components/messages/subscribe" + } + } + }, + "unsubscribe": { + "address": "/", + "messages": { + "unsubscribe": { + "$ref": "#/components/messages/unsubscribe" + } + } + } + }, + "operations": { + "receivePing": { + "action": "receive", + "channel": { + "$ref": "#/channels/ping" + }, + "reply": { + "channel": { + "$ref": "#/channels/pong" + } + } + }, + "heartbeat": { + "action": "send", + "channel": { + "$ref": "#/channels/heartbeat" + } + }, + "systemStatus": { + "action": "send", + "channel": { + "$ref": "#/channels/systemStatus" + } + }, + "subscribe": { + "action": "receive", + "channel": { + "$ref": "#/channels/subscribe" + }, + "reply": { + "channel": { + "$ref": "#/channels/currencyInfo" + } + } + }, + "unsubscribe": { + "action": "receive", + "channel": { + "$ref": "#/channels/unsubscribe" + }, + "reply": { + "channel": { + "$ref": "#/channels/currencyInfo" + }, + "messages": [ + { + "$ref": "#/channels/currencyInfo/messages/subscriptionStatus" + } + ] + } + } + }, + "components": { + "messages": { + "dummyCurrencyInfo": { + "summary": "Dummy message with no real life details", + "description": "It is here in this example to showcase that there is an additional message that normally is of a complex structure. It represents actually currency exchange value to show a reply to operation receiveSubscribeRequest with more than one possible message.", + "payload": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "currencyInfo" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "data": { + "type": "object" + } + }, + "required": [ + "event" + ] + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "ping": { + "summary": "Ping server to determine whether connection is alive", + "description": "Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated", + "payload": { + "$ref": "#/components/schemas/ping" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "pong": { + "summary": "Pong is a response to ping message", + "description": "Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in websockets standard which is sent by client in response to a ping", + "payload": { + "$ref": "#/components/schemas/pong" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "subscribe": { + "description": "Subscribe to a topic on a single or multiple currency pairs.", + "payload": { + "$ref": "#/components/schemas/subscribe" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "unsubscribe": { + "description": "Unsubscribe, can specify a channelID or multiple currency pairs.", + "payload": { + "$ref": "#/components/schemas/unsubscribe" + }, + "correlationId": { + "location": "$message.payload#/reqid" + } + }, + "subscriptionStatus": { + "description": "Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.", + "payload": { + "$ref": "#/components/schemas/subscriptionStatus" + }, + "examples": [ + { + "payload": { + "channelID": 10001, + "channelName": "ohlc-5", + "event": "subscriptionStatus", + "pair": "XBT/EUR", + "reqid": 42, + "status": "unsubscribed", + "subscription": { + "interval": 5, + "name": "ohlc" + } + } + }, + { + "payload": { + "errorMessage": "Subscription depth not supported", + "event": "subscriptionStatus", + "pair": "XBT/USD", + "status": "error", + "subscription": { + "depth": 42, + "name": "book" + } + } + } + ] + }, + "systemStatus": { + "description": "Status sent on connection or system status changes.", + "payload": { + "$ref": "#/components/schemas/systemStatus" + } + }, + "heartbeat": { + "description": "Server heartbeat sent if no subscription traffic within 1 second (approximately)", + "payload": { + "$ref": "#/components/schemas/heartbeat" + } + } + }, + "schemas": { + "ping": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "ping" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + } + }, + "required": [ + "event" + ] + }, + "heartbeat": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "heartbeat" + } + } + }, + "pong": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "pong" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + } + } + }, + "systemStatus": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "systemStatus" + }, + "connectionID": { + "type": "integer", + "description": "The ID of the connection" + }, + "status": { + "$ref": "#/components/schemas/status" + }, + "version": { + "type": "string" + } + } + }, + "status": { + "type": "string", + "enum": [ + "online", + "maintenance", + "cancel_only", + "limit_only", + "post_only" + ] + }, + "subscribe": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "subscribe" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "subscription": { + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "ratecounter": { + "$ref": "#/components/schemas/ratecounter" + }, + "snapshot": { + "$ref": "#/components/schemas/snapshot" + }, + "token": { + "$ref": "#/components/schemas/token" + } + }, + "required": [ + "name" + ] + } + }, + "required": [ + "event" + ] + }, + "unsubscribe": { + "type": "object", + "properties": { + "event": { + "type": "string", + "const": "unsubscribe" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "subscription": { + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "token": { + "$ref": "#/components/schemas/token" + } + }, + "required": [ + "name" + ] + } + }, + "required": [ + "event" + ] + }, + "subscriptionStatus": { + "type": "object", + "oneOf": [ + { + "$ref": "#/components/schemas/subscriptionStatusError" + }, + { + "$ref": "#/components/schemas/subscriptionStatusSuccess" + } + ] + }, + "subscriptionStatusError": { + "allOf": [ + { + "properties": { + "errorMessage": { + "type": "string" + } + }, + "required": [ + "errorMessage" + ] + }, + { + "$ref": "#/components/schemas/subscriptionStatusCommon" + } + ] + }, + "subscriptionStatusSuccess": { + "allOf": [ + { + "properties": { + "channelID": { + "type": "integer", + "description": "ChannelID on successful subscription, applicable to public messages only." + }, + "channelName": { + "type": "string", + "description": "Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix." + } + }, + "required": [ + "channelID", + "channelName" + ] + }, + { + "$ref": "#/components/schemas/subscriptionStatusCommon" + } + ] + }, + "subscriptionStatusCommon": { + "type": "object", + "required": [ + "event" + ], + "properties": { + "event": { + "type": "string", + "const": "subscriptionStatus" + }, + "reqid": { + "$ref": "#/components/schemas/reqid" + }, + "pair": { + "$ref": "#/components/schemas/pair" + }, + "status": { + "$ref": "#/components/schemas/status" + }, + "subscription": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "depth": { + "$ref": "#/components/schemas/depth" + }, + "interval": { + "$ref": "#/components/schemas/interval" + }, + "maxratecount": { + "$ref": "#/components/schemas/maxratecount" + }, + "name": { + "$ref": "#/components/schemas/name" + }, + "token": { + "$ref": "#/components/schemas/token" + } + } + } + } + }, + "interval": { + "type": "integer", + "description": "Time interval associated with ohlc subscription in minutes.", + "default": 1, + "enum": [ + 1, + 5, + 15, + 30, + 60, + 240, + 1440, + 10080, + 21600 + ] + }, + "name": { + "type": "string", + "description": "The name of the channel you subscribe too.", + "enum": [ + "book", + "ohlc", + "openOrders", + "ownTrades", + "spread", + "ticker", + "trade" + ] + }, + "token": { + "type": "string", + "description": "base64-encoded authentication token for private-data endpoints." + }, + "depth": { + "type": "integer", + "default": 10, + "enum": [ + 10, + 25, + 100, + 500, + 1000 + ], + "description": "Depth associated with book subscription in number of levels each side." + }, + "maxratecount": { + "type": "integer", + "description": "Max rate-limit budget. Compare to the ratecounter field in the openOrders updates to check whether you are approaching the rate limit." + }, + "ratecounter": { + "type": "boolean", + "default": false, + "description": "Whether to send rate-limit counter in updates (supported only for openOrders subscriptions)" + }, + "snapshot": { + "type": "boolean", + "default": true, + "description": "Whether to send historical feed data snapshot upon subscription (supported only for ownTrades subscriptions)" + }, + "reqid": { + "type": "integer", + "description": "client originated ID reflected in response message." + }, + "pair": { + "type": "array", + "description": "Array of currency pairs.", + "items": { + "type": "string", + "description": "Format of each pair is \"A/B\", where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized.", + "pattern": "[A-Z\\s]+\\/[A-Z\\s]+" + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/mercure-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/mercure-asyncapi.json new file mode 100644 index 00000000..398b0df6 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/mercure-asyncapi.json @@ -0,0 +1,88 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Mercure Hub Example", + "version": "1.0.0", + "description": "This example demonstrates how to define a Mercure hub." + }, + "defaultContentType": "application/ld+json", + "servers": { + "production": { + "host": "demo.mercure.rocks", + "pathname": "/.well-known/mercure", + "protocol": "mercure" + } + }, + "channels": { + "books": { + "address": "https://example.com/books/{id}", + "messages": { + "book": { + "$ref": "#/components/messages/book" + } + }, + "description": "Every time a resource of type `http://schema.org/Book` is created or modified, a JSON-LD representation of the new version of this resource must be pushed in this Mercure topic.", + "parameters": { + "id": { + "description": "ID of the book" + } + } + } + }, + "operations": { + "ReceiveBooksInfo": { + "action": "receive", + "channel": { + "$ref": "#/channels/books" + }, + "messages": [ + { + "$ref": "#/channels/books/messages/book" + } + ] + }, + "SendBooksInfo": { + "action": "send", + "channel": { + "$ref": "#/channels/books" + }, + "messages": [ + { + "$ref": "#/channels/books/messages/book" + } + ] + } + }, + "components": { + "messages": { + "book": { + "summary": "The content of a book resource.", + "externalDocs": { + "url": "https://schema.org/Book" + }, + "payload": { + "type": "object", + "properties": { + "@id": { + "type": "string", + "format": "iri-reference" + }, + "@type": { + "type": "string", + "format": "iri-reference" + }, + "name": { + "type": "string" + }, + "isbn": { + "type": "string" + }, + "abstract": { + "type": "string" + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/not-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/not-asyncapi.json new file mode 100644 index 00000000..38f856d8 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/not-asyncapi.json @@ -0,0 +1,51 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Not example", + "version": "1.0.0" + }, + "channels": { + "test": { + "address": "test", + "messages": { + "testMessages": { + "$ref": "#/components/messages/testMessages" + } + } + } + }, + "operations": { + "onTestMsg": { + "action": "receive", + "channel": { + "$ref": "#/channels/test" + }, + "messages": [ + { + "$ref": "#/channels/test/messages/testMessages" + } + ] + } + }, + "components": { + "messages": { + "testMessages": { + "payload": { + "$ref": "#/components/schemas/testSchema" + } + } + }, + "schemas": { + "testSchema": { + "type": "object", + "properties": { + "key": { + "not": { + "type": "integer" + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/oneof-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/oneof-asyncapi.json new file mode 100644 index 00000000..87310942 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/oneof-asyncapi.json @@ -0,0 +1,103 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "OneOf example", + "version": "1.0.0" + }, + "channels": { + "test": { + "address": "test", + "messages": { + "testMessages": { + "$ref": "#/components/messages/testMessages" + } + } + }, + "test2": { + "address": "test2", + "messages": { + "objectWithKey": { + "payload": { + "$ref": "#/components/schemas/objectWithKey" + } + }, + "objectWithKey2": { + "payload": { + "$ref": "#/components/schemas/objectWithKey2" + } + } + } + } + }, + "operations": { + "onTestMsg": { + "action": "receive", + "channel": { + "$ref": "#/channels/test" + }, + "messages": [ + { + "$ref": "#/channels/test/messages/testMessages" + } + ] + }, + "sendTest": { + "action": "send", + "channel": { + "$ref": "#/channels/test2" + }, + "messages": [ + { + "$ref": "#/channels/test2/messages/objectWithKey" + }, + { + "$ref": "#/channels/test2/messages/objectWithKey2" + } + ] + } + }, + "components": { + "messages": { + "testMessages": { + "payload": { + "oneOf": [ + { + "$ref": "#/components/schemas/objectWithKey" + }, + { + "$ref": "#/components/schemas/objectWithKey2" + } + ] + } + }, + "testMessage1": { + "payload": { + "$ref": "#/components/schemas/objectWithKey" + } + }, + "testMessage2": { + "payload": { + "$ref": "#/components/schemas/objectWithKey2" + } + } + }, + "schemas": { + "objectWithKey": { + "type": "object", + "properties": { + "key": { + "type": "string" + } + } + }, + "objectWithKey2": { + "type": "object", + "properties": { + "key2": { + "type": "string" + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/operation-security-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/operation-security-asyncapi.json new file mode 100644 index 00000000..7a473328 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/operation-security-asyncapi.json @@ -0,0 +1,175 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Notifications", + "version": "1.0.0", + "description": "This contract defines HTTP Push notification for application authorization revocation topic" + }, + "channels": { + "authRevoke": { + "address": "AUTHORIZATION_REVOCATION", + "messages": { + "message": { + "$ref": "#/components/messages/message" + } + } + } + }, + "operations": { + "sendAuthRevoke": { + "action": "send", + "channel": { + "$ref": "#/channels/authRevoke" + }, + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "subscribe:auth_revocations": "Scope required for authorization revocation topic" + } + } + }, + "scopes": [ + "subscribe:auth_revocations" + ] + } + ], + "bindings": { + "http": { + "method": "POST" + } + }, + "messages": [ + { + "$ref": "#/channels/authRevoke/messages/message" + } + ] + } + }, + "components": { + "messages": { + "message": { + "headers": { + "type": "object", + "properties": { + "X-SIGNATURE": { + "description": "ECC message signature", + "type": "string" + }, + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + }, + "payload": { + "type": "object", + "properties": { + "metadata": { + "$ref": "#/components/schemas/MetaData" + }, + "notification": { + "$ref": "#/components/schemas/Notification" + } + } + } + } + }, + "schemas": { + "MetaData": { + "type": "object", + "properties": { + "topic": { + "type": "string", + "description": "Topic subscribed to." + }, + "schemaVersion": { + "type": "string", + "description": "The schema for this topic." + }, + "deprecated": { + "type": "boolean", + "description": "If this is a deprecated schema or topic.", + "default": "false" + } + } + }, + "Notification": { + "type": "object", + "properties": { + "notificationId": { + "type": "string", + "description": "The notification Id." + }, + "eventDate": { + "type": "string", + "description": "The event date associated with this notification in UTC." + }, + "publishDate": { + "type": "string", + "description": "The message publish date in UTC." + }, + "publishAttemptCount": { + "type": "integer", + "description": "The number of attempts made to publish this message." + }, + "data": { + "$ref": "#/components/schemas/AuthorizationRevocationData" + } + } + }, + "AuthorizationRevocationData": { + "type": "object", + "description": "The Authorization Revocation payload.", + "properties": { + "username": { + "type": "string", + "description": "The username for the user." + }, + "userId": { + "type": "string", + "description": "The immutable public userId for the user" + }, + "eiasToken": { + "type": "string", + "description": "The legacy eiasToken specific to the user" + }, + "revokeReason": { + "type": "string", + "enum": [ + "REVOKED_BY_APP", + "REVOKED_BY_USER", + "REVOKED_BY_ADMIN", + "PASSWORD_CHANGE" + ], + "description": "The reason for authorization revocation" + }, + "revocationDate": { + "type": "string", + "description": "Date and time when the authorization was revoked" + } + } + } + }, + "securitySchemes": { + "petstore_auth": { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "subscribe:auth_revocations": "Scope required for authorization revocation topic" + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-client-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-client-asyncapi.json new file mode 100644 index 00000000..22a78845 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-client-asyncapi.json @@ -0,0 +1,119 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:example:rpcclient", + "info": { + "title": "RPC Client Example", + "version": "1.0.0", + "description": "This example demonstrates how to define an RPC client." + }, + "defaultContentType": "application/json", + "servers": { + "production": { + "host": "rabbitmq.example.org", + "protocol": "amqp" + } + }, + "channels": { + "queue": { + "address": "{queue}", + "messages": { + "receiveSumResult": { + "correlationId": { + "location": "$message.header#/correlation_id" + }, + "payload": { + "type": "object", + "properties": { + "result": { + "type": "number", + "examples": [ + 7 + ] + } + } + } + } + }, + "parameters": { + "queue": {} + }, + "bindings": { + "amqp": { + "is": "queue", + "queue": { + "exclusive": true + } + } + } + }, + "rpc_queue": { + "address": "rpc_queue", + "messages": { + "requestSum": { + "correlationId": { + "location": "$message.header#/correlation_id" + }, + "payload": { + "type": "object", + "properties": { + "numbers": { + "type": "array", + "items": { + "type": "number" + }, + "examples": [ + [ + 4, + 3 + ] + ] + } + } + } + } + }, + "bindings": { + "amqp": { + "is": "queue", + "queue": { + "durable": false + } + } + } + } + }, + "operations": { + "receiveSumResult": { + "action": "receive", + "channel": { + "$ref": "#/channels/queue" + }, + "bindings": { + "amqp": { + "ack": false + } + }, + "messages": [ + { + "$ref": "#/channels/queue/messages/receiveSumResult" + } + ] + }, + "requestSum": { + "action": "send", + "channel": { + "$ref": "#/channels/rpc_queue" + }, + "bindings": { + "amqp": { + "ack": true + } + }, + "messages": [ + { + "$ref": "#/channels/rpc_queue/messages/requestSum" + } + ] + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-server-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-server-asyncapi.json new file mode 100644 index 00000000..346e6a46 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/rpc-server-asyncapi.json @@ -0,0 +1,114 @@ +{ + "asyncapi": "3.0.0", + "id": "urn:example:rpcserver", + "info": { + "title": "RPC Server Example", + "version": "1.0.0", + "description": "This example demonstrates how to define an RPC server." + }, + "defaultContentType": "application/json", + "servers": { + "production": { + "host": "rabbitmq.example.org", + "protocol": "amqp" + } + }, + "channels": { + "queue": { + "address": "{queue}", + "messages": { + "sendSumResult": { + "correlationId": { + "location": "$message.header#/correlation_id" + }, + "payload": { + "type": "object", + "properties": { + "result": { + "type": "number", + "examples": [ + 7 + ] + } + } + } + } + }, + "parameters": { + "queue": {} + }, + "bindings": { + "amqp": { + "is": "queue", + "queue": { + "exclusive": true + } + } + } + }, + "rpc_queue": { + "address": "rpc_queue", + "messages": { + "sum": { + "correlationId": { + "location": "$message.header#/correlation_id" + }, + "payload": { + "type": "object", + "properties": { + "numbers": { + "type": "array", + "items": { + "type": "number" + }, + "examples": [ + [ + 4, + 3 + ] + ] + } + } + } + } + }, + "bindings": { + "amqp": { + "is": "queue", + "queue": { + "durable": false + } + } + } + } + }, + "operations": { + "sendSumResult": { + "action": "send", + "channel": { + "$ref": "#/channels/queue" + }, + "bindings": { + "amqp": { + "ack": true + } + }, + "messages": [ + { + "$ref": "#/channels/queue/messages/sendSumResult" + } + ] + }, + "sum": { + "action": "receive", + "channel": { + "$ref": "#/channels/rpc_queue" + }, + "messages": [ + { + "$ref": "#/channels/rpc_queue/messages/sum" + } + ] + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/simple-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/simple-asyncapi.json new file mode 100644 index 00000000..5434a342 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/simple-asyncapi.json @@ -0,0 +1,51 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "userSignedup": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/UserSignedUp" + } + } + } + }, + "operations": { + "sendUserSignedup": { + "action": "send", + "channel": { + "$ref": "#/channels/userSignedup" + }, + "messages": [ + { + "$ref": "#/channels/userSignedup/messages/UserSignedUp" + } + ] + } + }, + "components": { + "messages": { + "UserSignedUp": { + "payload": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/slack-rtm-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/slack-rtm-asyncapi.json new file mode 100644 index 00000000..9b8ff39a --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/slack-rtm-asyncapi.json @@ -0,0 +1,1578 @@ +{ + "asyncapi": "3.0.0", + "id": "wss://wss-primary.slack.com/websocket", + "info": { + "title": "Slack Real Time Messaging API", + "version": "1.0.0" + }, + "servers": { + "production": { + "host": "slack.com", + "pathname": "/api/rtm.connect", + "protocol": "https", + "protocolVersion": "1.1", + "security": [ + { + "$ref": "#/components/securitySchemes/token" + } + ] + } + }, + "channels": { + "root": { + "address": "/", + "messages": { + "outgoingMessage": { + "$ref": "#/components/messages/outgoingMessage" + }, + "hello": { + "$ref": "#/components/messages/hello" + }, + "connectionError": { + "$ref": "#/components/messages/connectionError" + }, + "accountsChanged": { + "$ref": "#/components/messages/accountsChanged" + }, + "botAdded": { + "$ref": "#/components/messages/botAdded" + }, + "botChanged": { + "$ref": "#/components/messages/botChanged" + }, + "channelArchive": { + "$ref": "#/components/messages/channelArchive" + }, + "channelCreated": { + "$ref": "#/components/messages/channelCreated" + }, + "channelDeleted": { + "$ref": "#/components/messages/channelDeleted" + }, + "channelHistoryChanged": { + "$ref": "#/components/messages/channelHistoryChanged" + }, + "channelJoined": { + "$ref": "#/components/messages/channelJoined" + }, + "channelLeft": { + "$ref": "#/components/messages/channelLeft" + }, + "channelMarked": { + "$ref": "#/components/messages/channelMarked" + }, + "channelRename": { + "$ref": "#/components/messages/channelRename" + }, + "channelUnarchive": { + "$ref": "#/components/messages/channelUnarchive" + }, + "commandsChanged": { + "$ref": "#/components/messages/commandsChanged" + }, + "dndUpdated": { + "$ref": "#/components/messages/dndUpdated" + }, + "dndUpdatedUser": { + "$ref": "#/components/messages/dndUpdatedUser" + }, + "emailDomainChanged": { + "$ref": "#/components/messages/emailDomainChanged" + }, + "emojiRemoved": { + "$ref": "#/components/messages/emojiRemoved" + }, + "emojiAdded": { + "$ref": "#/components/messages/emojiAdded" + }, + "fileChange": { + "$ref": "#/components/messages/fileChange" + }, + "fileCommentAdded": { + "$ref": "#/components/messages/fileCommentAdded" + }, + "fileCommentDeleted": { + "$ref": "#/components/messages/fileCommentDeleted" + }, + "fileCommentEdited": { + "$ref": "#/components/messages/fileCommentEdited" + }, + "fileCreated": { + "$ref": "#/components/messages/fileCreated" + }, + "fileDeleted": { + "$ref": "#/components/messages/fileDeleted" + }, + "filePublic": { + "$ref": "#/components/messages/filePublic" + }, + "fileShared": { + "$ref": "#/components/messages/fileShared" + }, + "fileUnshared": { + "$ref": "#/components/messages/fileUnshared" + }, + "goodbye": { + "$ref": "#/components/messages/goodbye" + }, + "groupArchive": { + "$ref": "#/components/messages/groupArchive" + }, + "groupClose": { + "$ref": "#/components/messages/groupClose" + }, + "groupHistoryChanged": { + "$ref": "#/components/messages/groupHistoryChanged" + }, + "groupJoined": { + "$ref": "#/components/messages/groupJoined" + }, + "groupLeft": { + "$ref": "#/components/messages/groupLeft" + }, + "groupMarked": { + "$ref": "#/components/messages/groupMarked" + }, + "groupOpen": { + "$ref": "#/components/messages/groupOpen" + }, + "groupRename": { + "$ref": "#/components/messages/groupRename" + }, + "groupUnarchive": { + "$ref": "#/components/messages/groupUnarchive" + }, + "imClose": { + "$ref": "#/components/messages/imClose" + }, + "imCreated": { + "$ref": "#/components/messages/imCreated" + }, + "imMarked": { + "$ref": "#/components/messages/imMarked" + }, + "imOpen": { + "$ref": "#/components/messages/imOpen" + }, + "manualPresenceChange": { + "$ref": "#/components/messages/manualPresenceChange" + }, + "memberJoinedChannel": { + "$ref": "#/components/messages/memberJoinedChannel" + }, + "message": { + "$ref": "#/components/messages/message" + } + } + } + }, + "operations": { + "receiveOutgoingMessage": { + "action": "receive", + "channel": { + "$ref": "#/channels/root" + }, + "messages": [ + { + "$ref": "#/channels/root/messages/outgoingMessage" + } + ] + }, + "sendMessages": { + "action": "send", + "channel": { + "$ref": "#/channels/root" + }, + "messages": [ + { + "$ref": "#/channels/root/messages/hello" + }, + { + "$ref": "#/channels/root/messages/connectionError" + }, + { + "$ref": "#/channels/root/messages/accountsChanged" + }, + { + "$ref": "#/channels/root/messages/botAdded" + }, + { + "$ref": "#/channels/root/messages/botChanged" + }, + { + "$ref": "#/channels/root/messages/channelArchive" + }, + { + "$ref": "#/channels/root/messages/channelCreated" + }, + { + "$ref": "#/channels/root/messages/channelDeleted" + }, + { + "$ref": "#/channels/root/messages/channelHistoryChanged" + }, + { + "$ref": "#/channels/root/messages/channelJoined" + }, + { + "$ref": "#/channels/root/messages/channelLeft" + }, + { + "$ref": "#/channels/root/messages/channelMarked" + }, + { + "$ref": "#/channels/root/messages/channelRename" + }, + { + "$ref": "#/channels/root/messages/channelUnarchive" + }, + { + "$ref": "#/channels/root/messages/commandsChanged" + }, + { + "$ref": "#/channels/root/messages/dndUpdated" + }, + { + "$ref": "#/channels/root/messages/dndUpdatedUser" + }, + { + "$ref": "#/channels/root/messages/emailDomainChanged" + }, + { + "$ref": "#/channels/root/messages/emojiRemoved" + }, + { + "$ref": "#/channels/root/messages/emojiAdded" + }, + { + "$ref": "#/channels/root/messages/fileChange" + }, + { + "$ref": "#/channels/root/messages/fileCommentAdded" + }, + { + "$ref": "#/channels/root/messages/fileCommentDeleted" + }, + { + "$ref": "#/channels/root/messages/fileCommentEdited" + }, + { + "$ref": "#/channels/root/messages/fileCreated" + }, + { + "$ref": "#/channels/root/messages/fileDeleted" + }, + { + "$ref": "#/channels/root/messages/filePublic" + }, + { + "$ref": "#/channels/root/messages/fileShared" + }, + { + "$ref": "#/channels/root/messages/fileUnshared" + }, + { + "$ref": "#/channels/root/messages/goodbye" + }, + { + "$ref": "#/channels/root/messages/groupArchive" + }, + { + "$ref": "#/channels/root/messages/groupClose" + }, + { + "$ref": "#/channels/root/messages/groupHistoryChanged" + }, + { + "$ref": "#/channels/root/messages/groupJoined" + }, + { + "$ref": "#/channels/root/messages/groupLeft" + }, + { + "$ref": "#/channels/root/messages/groupMarked" + }, + { + "$ref": "#/channels/root/messages/groupOpen" + }, + { + "$ref": "#/channels/root/messages/groupRename" + }, + { + "$ref": "#/channels/root/messages/groupUnarchive" + }, + { + "$ref": "#/channels/root/messages/imClose" + }, + { + "$ref": "#/channels/root/messages/imCreated" + }, + { + "$ref": "#/channels/root/messages/imMarked" + }, + { + "$ref": "#/channels/root/messages/imOpen" + }, + { + "$ref": "#/channels/root/messages/manualPresenceChange" + }, + { + "$ref": "#/channels/root/messages/memberJoinedChannel" + }, + { + "$ref": "#/channels/root/messages/message" + } + ] + } + }, + "components": { + "securitySchemes": { + "token": { + "type": "httpApiKey", + "name": "token", + "in": "query" + } + }, + "schemas": { + "attachment": { + "type": "object", + "properties": { + "fallback": { + "type": "string" + }, + "color": { + "type": "string" + }, + "pretext": { + "type": "string" + }, + "author_name": { + "type": "string" + }, + "author_link": { + "type": "string", + "format": "uri" + }, + "author_icon": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "title_link": { + "type": "string", + "format": "uri" + }, + "text": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "value": { + "type": "string" + }, + "short": { + "type": "boolean" + } + } + } + }, + "image_url": { + "type": "string", + "format": "uri" + }, + "thumb_url": { + "type": "string", + "format": "uri" + }, + "footer": { + "type": "string" + }, + "footer_icon": { + "type": "string", + "format": "uri" + }, + "ts": { + "type": "number" + } + } + } + }, + "messages": { + "hello": { + "summary": "First event received upon connection.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "hello" + ] + } + } + } + }, + "connectionError": { + "summary": "Event received when a connection error happens.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "error" + ] + }, + "error": { + "type": "object", + "properties": { + "code": { + "type": "number" + }, + "msg": { + "type": "string" + } + } + } + } + } + }, + "accountsChanged": { + "summary": "The list of accounts a user is signed into has changed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "accounts_changed" + ] + } + } + } + }, + "botAdded": { + "summary": "A bot user was added.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "bot_added" + ] + }, + "bot": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "app_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "icons": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "botChanged": { + "summary": "A bot user was changed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "bot_added" + ] + }, + "bot": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "app_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "icons": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "channelArchive": { + "summary": "A channel was archived.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_archive" + ] + }, + "channel": { + "type": "string" + }, + "user": { + "type": "string" + } + } + } + }, + "channelCreated": { + "summary": "A channel was created.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_created" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + }, + "creator": { + "type": "string" + } + } + } + } + } + }, + "channelDeleted": { + "summary": "A channel was deleted.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_deleted" + ] + }, + "channel": { + "type": "string" + } + } + } + }, + "channelHistoryChanged": { + "summary": "Bulk updates were made to a channel's history.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_history_changed" + ] + }, + "latest": { + "type": "string" + }, + "ts": { + "type": "string" + }, + "event_ts": { + "type": "string" + } + } + } + }, + "channelJoined": { + "summary": "You joined a channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_joined" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + }, + "creator": { + "type": "string" + } + } + } + } + } + }, + "channelLeft": { + "summary": "You left a channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_left" + ] + }, + "channel": { + "type": "string" + } + } + } + }, + "channelMarked": { + "summary": "Your channel read marker was updated.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_marked" + ] + }, + "channel": { + "type": "string" + }, + "ts": { + "type": "string" + } + } + } + }, + "channelRename": { + "summary": "A channel was renamed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_rename" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + } + } + } + } + } + }, + "channelUnarchive": { + "summary": "A channel was unarchived.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "channel_unarchive" + ] + }, + "channel": { + "type": "string" + }, + "user": { + "type": "string" + } + } + } + }, + "commandsChanged": { + "summary": "A slash command has been added or changed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "commands_changed" + ] + }, + "event_ts": { + "type": "string" + } + } + } + }, + "dndUpdated": { + "summary": "Do not Disturb settings changed for the current user.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "dnd_updated" + ] + }, + "user": { + "type": "string" + }, + "dnd_status": { + "type": "object", + "properties": { + "dnd_enabled": { + "type": "boolean" + }, + "next_dnd_start_ts": { + "type": "number" + }, + "next_dnd_end_ts": { + "type": "number" + }, + "snooze_enabled": { + "type": "boolean" + }, + "snooze_endtime": { + "type": "number" + } + } + } + } + } + }, + "dndUpdatedUser": { + "summary": "Do not Disturb settings changed for a member.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "dnd_updated_user" + ] + }, + "user": { + "type": "string" + }, + "dnd_status": { + "type": "object", + "properties": { + "dnd_enabled": { + "type": "boolean" + }, + "next_dnd_start_ts": { + "type": "number" + }, + "next_dnd_end_ts": { + "type": "number" + } + } + } + } + } + }, + "emailDomainChanged": { + "summary": "The workspace email domain has changed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "email_domain_changed" + ] + }, + "email_domain": { + "type": "string" + }, + "event_ts": { + "type": "string" + } + } + } + }, + "emojiRemoved": { + "summary": "A custom emoji has been removed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "emoji_changed" + ] + }, + "subtype": { + "type": "string", + "enum": [ + "remove" + ] + }, + "names": { + "type": "array", + "items": { + "type": "string" + } + }, + "event_ts": { + "type": "string" + } + } + } + }, + "emojiAdded": { + "summary": "A custom emoji has been added.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "emoji_changed" + ] + }, + "subtype": { + "type": "string", + "enum": [ + "add" + ] + }, + "name": { + "type": "string" + }, + "value": { + "type": "string", + "format": "uri" + }, + "event_ts": { + "type": "string" + } + } + } + }, + "fileChange": { + "summary": "A file was changed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_change" + ] + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileCommentAdded": { + "summary": "A file comment was added.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_comment_added" + ] + }, + "comment": {}, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileCommentDeleted": { + "summary": "A file comment was deleted.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_comment_deleted" + ] + }, + "comment": { + "type": "string" + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileCommentEdited": { + "summary": "A file comment was edited.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_comment_edited" + ] + }, + "comment": {}, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileCreated": { + "summary": "A file was created.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_created" + ] + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileDeleted": { + "summary": "A file was deleted.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_deleted" + ] + }, + "file_id": { + "type": "string" + }, + "event_ts": { + "type": "string" + } + } + } + }, + "filePublic": { + "summary": "A file was made public.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_public" + ] + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileShared": { + "summary": "A file was shared.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_shared" + ] + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "fileUnshared": { + "summary": "A file was unshared.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file_unshared" + ] + }, + "file_id": { + "type": "string" + }, + "file": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + } + } + }, + "goodbye": { + "summary": "The server intends to close the connection soon.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "goodbye" + ] + } + } + } + }, + "groupArchive": { + "summary": "A private channel was archived.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_archive" + ] + }, + "channel": { + "type": "string" + } + } + } + }, + "groupClose": { + "summary": "You closed a private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_close" + ] + }, + "user": { + "type": "string" + }, + "channel": { + "type": "string" + } + } + } + }, + "groupHistoryChanged": { + "summary": "Bulk updates were made to a private channel's history.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_history_changed" + ] + }, + "latest": { + "type": "string" + }, + "ts": { + "type": "string" + }, + "event_ts": { + "type": "string" + } + } + } + }, + "groupJoined": { + "summary": "You joined a private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_joined" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + }, + "creator": { + "type": "string" + } + } + } + } + } + }, + "groupLeft": { + "summary": "You left a private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_left" + ] + }, + "channel": { + "type": "string" + } + } + } + }, + "groupMarked": { + "summary": "A private channel read marker was updated.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_marked" + ] + }, + "channel": { + "type": "string" + }, + "ts": { + "type": "string" + } + } + } + }, + "groupOpen": { + "summary": "You opened a private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_open" + ] + }, + "user": { + "type": "string" + }, + "channel": { + "type": "string" + } + } + } + }, + "groupRename": { + "summary": "A private channel was renamed.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_rename" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + } + } + } + } + } + }, + "groupUnarchive": { + "summary": "A private channel was unarchived.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "group_unarchive" + ] + }, + "channel": { + "type": "string" + }, + "user": { + "type": "string" + } + } + } + }, + "imClose": { + "summary": "You closed a DM.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "im_close" + ] + }, + "channel": { + "type": "string" + }, + "user": { + "type": "string" + } + } + } + }, + "imCreated": { + "summary": "A DM was created.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "im_created" + ] + }, + "channel": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "created": { + "type": "number" + }, + "creator": { + "type": "string" + } + } + }, + "user": { + "type": "string" + } + } + } + }, + "imMarked": { + "summary": "A direct message read marker was updated.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "im_marked" + ] + }, + "channel": { + "type": "string" + }, + "ts": { + "type": "string" + } + } + } + }, + "imOpen": { + "summary": "You opened a DM.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "im_open" + ] + }, + "channel": { + "type": "string" + }, + "user": { + "type": "string" + } + } + } + }, + "manualPresenceChange": { + "summary": "You manually updated your presence.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "manual_presence_change" + ] + }, + "presence": { + "type": "string" + } + } + } + }, + "memberJoinedChannel": { + "summary": "A user joined a public or private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "member_joined_channel" + ] + }, + "user": { + "type": "string" + }, + "channel": { + "type": "string" + }, + "channel_type": { + "type": "string", + "enum": [ + "C", + "G" + ] + }, + "team": { + "type": "string" + }, + "inviter": { + "type": "string" + } + } + } + }, + "memberLeftChannel": { + "summary": "A user left a public or private channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "member_left_channel" + ] + }, + "user": { + "type": "string" + }, + "channel": { + "type": "string" + }, + "channel_type": { + "type": "string", + "enum": [ + "C", + "G" + ] + }, + "team": { + "type": "string" + } + } + } + }, + "message": { + "summary": "A message was sent to a channel.", + "payload": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "message" + ] + }, + "user": { + "type": "string" + }, + "channel": { + "type": "string" + }, + "text": { + "type": "string" + }, + "ts": { + "type": "string" + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/attachment" + } + }, + "edited": { + "type": "object", + "properties": { + "user": { + "type": "string" + }, + "ts": { + "type": "string" + } + } + } + } + } + }, + "outgoingMessage": { + "summary": "A message was sent to a channel.", + "payload": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "type": { + "type": "string", + "enum": [ + "message" + ] + }, + "channel": { + "type": "string" + }, + "text": { + "type": "string" + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-kafka-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-kafka-asyncapi.json new file mode 100644 index 00000000..e4b2e63d --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-kafka-asyncapi.json @@ -0,0 +1,322 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Streetlights Kafka API", + "version": "1.0.0", + "description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off πŸŒƒ\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions πŸ“ˆ\n", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "defaultContentType": "application/json", + "servers": { + "scram-connections": { + "host": "test.mykafkacluster.org:18092", + "protocol": "kafka-secure", + "description": "Test broker secured with scramSha256", + "security": [ + { + "$ref": "#/components/securitySchemes/saslScram" + } + ], + "tags": [ + { + "name": "env:test-scram", + "description": "This environment is meant for running internal tests through scramSha256" + }, + { + "name": "kind:remote", + "description": "This server is a remote server. Not exposed by the application" + }, + { + "name": "visibility:private", + "description": "This resource is private and only available to certain users" + } + ] + }, + "mtls-connections": { + "host": "test.mykafkacluster.org:28092", + "protocol": "kafka-secure", + "description": "Test broker secured with X509", + "security": [ + { + "$ref": "#/components/securitySchemes/certs" + } + ], + "tags": [ + { + "name": "env:test-mtls", + "description": "This environment is meant for running internal tests through mtls" + }, + { + "name": "kind:remote", + "description": "This server is a remote server. Not exposed by the application" + }, + { + "name": "visibility:private", + "description": "This resource is private and only available to certain users" + } + ] + } + }, + "channels": { + "lightingMeasured": { + "address": "smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured", + "messages": { + "lightMeasured": { + "$ref": "#/components/messages/lightMeasured" + } + }, + "description": "The topic on which measured values may be produced and consumed.", + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOn": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.turn.on", + "messages": { + "turnOn": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOff": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.turn.off", + "messages": { + "turnOff": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightsDim": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.dim", + "messages": { + "dimLight": { + "$ref": "#/components/messages/dimLight" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + } + }, + "operations": { + "receiveLightMeasurement": { + "action": "receive", + "channel": { + "$ref": "#/channels/lightingMeasured" + }, + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + }, + "turnOn": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOn" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOn/messages/turnOn" + } + ] + }, + "turnOff": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOff" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOff/messages/turnOff" + } + ] + }, + "dimLight": { + "action": "send", + "channel": { + "$ref": "#/channels/lightsDim" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightsDim/messages/dimLight" + } + ] + } + }, + "components": { + "messages": { + "lightMeasured": { + "name": "lightMeasured", + "title": "Light measured", + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "contentType": "application/json", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/lightMeasuredPayload" + } + }, + "turnOnOff": { + "name": "turnOnOff", + "title": "Turn on/off", + "summary": "Command a particular streetlight to turn the lights on or off.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/turnOnOffPayload" + } + }, + "dimLight": { + "name": "dimLight", + "title": "Dim light", + "summary": "Command a particular streetlight to dim the lights.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/dimLightPayload" + } + } + }, + "schemas": { + "lightMeasuredPayload": { + "type": "object", + "properties": { + "lumens": { + "type": "integer", + "minimum": 0, + "description": "Light intensity measured in lumens." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "turnOnOffPayload": { + "type": "object", + "properties": { + "command": { + "type": "string", + "enum": [ + "on", + "off" + ], + "description": "Whether to turn on or off the light." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "dimLightPayload": { + "type": "object", + "properties": { + "percentage": { + "type": "integer", + "description": "Percentage to which the light should be dimmed to.", + "minimum": 0, + "maximum": 100 + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "sentAt": { + "type": "string", + "format": "date-time", + "description": "Date and time when the message was sent." + } + }, + "securitySchemes": { + "saslScram": { + "type": "scramSha256", + "description": "Provide your username and password for SASL/SCRAM authentication" + }, + "certs": { + "type": "X509", + "description": "Download the certificate files from service provider" + } + }, + "parameters": { + "streetlightId": { + "description": "The ID of the streetlight." + } + }, + "messageTraits": { + "commonHeaders": { + "headers": { + "type": "object", + "properties": { + "my-app-header": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + } + } + } + }, + "operationTraits": { + "kafka": { + "bindings": { + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-mqtt-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-mqtt-asyncapi.json new file mode 100644 index 00000000..75e0f4bd --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-mqtt-asyncapi.json @@ -0,0 +1,392 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Streetlights MQTT API", + "version": "1.0.0", + "description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off πŸŒƒ\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions πŸ“ˆ\n", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "defaultContentType": "application/json", + "servers": { + "production": { + "host": "test.mosquitto.org:{port}", + "protocol": "mqtt", + "description": "Test broker", + "variables": { + "port": { + "description": "Secure connection (TLS) is available through port 8883.", + "default": "1883", + "enum": [ + "1883", + "8883" + ] + } + }, + "security": [ + { + "$ref": "#/components/securitySchemes/apiKey" + }, + { + "type": "oauth2", + "description": "Flows to support OAuth 2.0", + "flows": { + "implicit": { + "authorizationUrl": "https://authserver.example/auth", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "password": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "clientCredentials": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "authorizationCode": { + "authorizationUrl": "https://authserver.example/auth", + "tokenUrl": "https://authserver.example/token", + "refreshUrl": "https://authserver.example/refresh", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + } + }, + "scopes": [ + "streetlights:on", + "streetlights:off", + "streetlights:dim" + ] + }, + { + "$ref": "#/components/securitySchemes/openIdConnectWellKnown" + } + ], + "tags": [ + { + "name": "env:production", + "description": "This environment is meant for production use case" + }, + { + "name": "kind:remote", + "description": "This server is a remote server. Not exposed by the application" + }, + { + "name": "visibility:public", + "description": "This resource is public and available to everyone" + } + ] + } + }, + "channels": { + "lightingMeasured": { + "address": "smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured", + "messages": { + "lightMeasured": { + "$ref": "#/components/messages/lightMeasured" + } + }, + "description": "The topic on which measured values may be produced and consumed.", + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOn": { + "address": "smartylighting/streetlights/1/0/action/{streetlightId}/turn/on", + "messages": { + "turnOn": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOff": { + "address": "smartylighting/streetlights/1/0/action/{streetlightId}/turn/off", + "messages": { + "turnOff": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightsDim": { + "address": "smartylighting/streetlights/1/0/action/{streetlightId}/dim", + "messages": { + "dimLight": { + "$ref": "#/components/messages/dimLight" + } + }, + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + } + }, + "operations": { + "receiveLightMeasurement": { + "action": "receive", + "channel": { + "$ref": "#/channels/lightingMeasured" + }, + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "traits": [ + { + "$ref": "#/components/operationTraits/mqtt" + } + ], + "messages": [ + { + "$ref": "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + }, + "turnOn": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOn" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/mqtt" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOn/messages/turnOn" + } + ] + }, + "turnOff": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOff" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/mqtt" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOff/messages/turnOff" + } + ] + }, + "dimLight": { + "action": "send", + "channel": { + "$ref": "#/channels/lightsDim" + }, + "traits": [ + { + "$ref": "#/components/operationTraits/mqtt" + } + ], + "messages": [ + { + "$ref": "#/channels/lightsDim/messages/dimLight" + } + ] + } + }, + "components": { + "messages": { + "lightMeasured": { + "name": "lightMeasured", + "title": "Light measured", + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "contentType": "application/json", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/lightMeasuredPayload" + } + }, + "turnOnOff": { + "name": "turnOnOff", + "title": "Turn on/off", + "summary": "Command a particular streetlight to turn the lights on or off.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/turnOnOffPayload" + } + }, + "dimLight": { + "name": "dimLight", + "title": "Dim light", + "summary": "Command a particular streetlight to dim the lights.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/dimLightPayload" + } + } + }, + "schemas": { + "lightMeasuredPayload": { + "type": "object", + "properties": { + "lumens": { + "type": "integer", + "minimum": 0, + "description": "Light intensity measured in lumens." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "turnOnOffPayload": { + "type": "object", + "properties": { + "command": { + "type": "string", + "enum": [ + "on", + "off" + ], + "description": "Whether to turn on or off the light." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "dimLightPayload": { + "type": "object", + "properties": { + "percentage": { + "type": "integer", + "description": "Percentage to which the light should be dimmed to.", + "minimum": 0, + "maximum": 100 + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "sentAt": { + "type": "string", + "format": "date-time", + "description": "Date and time when the message was sent." + } + }, + "securitySchemes": { + "apiKey": { + "type": "apiKey", + "in": "user", + "description": "Provide your API key as the user and leave the password empty." + }, + "supportedOauthFlows": { + "type": "oauth2", + "description": "Flows to support OAuth 2.0", + "flows": { + "implicit": { + "authorizationUrl": "https://authserver.example/auth", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "password": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "clientCredentials": { + "tokenUrl": "https://authserver.example/token", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + }, + "authorizationCode": { + "authorizationUrl": "https://authserver.example/auth", + "tokenUrl": "https://authserver.example/token", + "refreshUrl": "https://authserver.example/refresh", + "availableScopes": { + "streetlights:on": "Ability to switch lights on", + "streetlights:off": "Ability to switch lights off", + "streetlights:dim": "Ability to dim the lights" + } + } + } + }, + "openIdConnectWellKnown": { + "type": "openIdConnect", + "openIdConnectUrl": "https://authserver.example/.well-known" + } + }, + "parameters": { + "streetlightId": { + "description": "The ID of the streetlight." + } + }, + "messageTraits": { + "commonHeaders": { + "headers": { + "type": "object", + "properties": { + "my-app-header": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + } + } + } + }, + "operationTraits": { + "mqtt": { + "bindings": { + "mqtt": { + "qos": 1 + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-operation-security-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-operation-security-asyncapi.json new file mode 100644 index 00000000..52194d3b --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/streetlights-operation-security-asyncapi.json @@ -0,0 +1,391 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Streetlights Kafka API", + "version": "1.0.0", + "description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off πŸŒƒ\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions πŸ“ˆ\n", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "defaultContentType": "application/json", + "servers": { + "test": { + "host": "test.mykafkacluster.org:8092", + "protocol": "kafka-secure", + "description": "Test broker", + "security": [ + { + "$ref": "#/components/securitySchemes/saslScram" + } + ] + }, + "test_oauth": { + "host": "test.mykafkacluster.org:8093", + "protocol": "kafka-secure", + "description": "Test port for oauth", + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "streetlights:read": "Scope required for subscribing to channel", + "streetlights:write": "Scope required for publishing to channel" + } + } + }, + "scopes": [ + "streetlights:write", + "streetlights:read" + ] + } + ] + } + }, + "channels": { + "lightingMeasured": { + "address": "smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured", + "messages": { + "lightMeasured": { + "$ref": "#/components/messages/lightMeasured" + } + }, + "description": "The topic on which measured values may be produced and consumed.", + "servers": [ + { + "$ref": "#/servers/test" + } + ], + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOn": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.turn.on", + "messages": { + "turnOn": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "servers": [ + { + "$ref": "#/servers/test_oauth" + } + ], + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightTurnOff": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.turn.off", + "messages": { + "turnOff": { + "$ref": "#/components/messages/turnOnOff" + } + }, + "servers": [ + { + "$ref": "#/servers/test_oauth" + } + ], + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + }, + "lightsDim": { + "address": "smartylighting.streetlights.1.0.action.{streetlightId}.dim", + "messages": { + "dimLight": { + "$ref": "#/components/messages/dimLight" + } + }, + "servers": [ + { + "$ref": "#/servers/test_oauth" + } + ], + "parameters": { + "streetlightId": { + "$ref": "#/components/parameters/streetlightId" + } + } + } + }, + "operations": { + "receiveLightMeasurement": { + "action": "receive", + "channel": { + "$ref": "#/channels/lightingMeasured" + }, + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + }, + "turnOn": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOn" + }, + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "streetlights:read": "Scope required for subscribing to channel", + "streetlights:write": "Scope required for publishing to channel" + } + } + }, + "scopes": [ + "streetlights:read" + ] + } + ], + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOn/messages/turnOn" + } + ] + }, + "turnOff": { + "action": "send", + "channel": { + "$ref": "#/channels/lightTurnOff" + }, + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "streetlights:read": "Scope required for subscribing to channel", + "streetlights:write": "Scope required for publishing to channel" + } + } + }, + "scopes": [ + "streetlights:read" + ] + } + ], + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightTurnOff/messages/turnOff" + } + ] + }, + "dimLight": { + "action": "send", + "channel": { + "$ref": "#/channels/lightsDim" + }, + "security": [ + { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "streetlights:read": "Scope required for subscribing to channel", + "streetlights:write": "Scope required for publishing to channel" + } + } + }, + "scopes": [ + "streetlights:read" + ] + } + ], + "traits": [ + { + "$ref": "#/components/operationTraits/kafka" + } + ], + "messages": [ + { + "$ref": "#/channels/lightsDim/messages/dimLight" + } + ] + } + }, + "components": { + "messages": { + "lightMeasured": { + "name": "lightMeasured", + "title": "Light measured", + "summary": "Inform about environmental lighting conditions of a particular streetlight.", + "contentType": "application/json", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/lightMeasuredPayload" + } + }, + "turnOnOff": { + "name": "turnOnOff", + "title": "Turn on/off", + "summary": "Command a particular streetlight to turn the lights on or off.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/turnOnOffPayload" + } + }, + "dimLight": { + "name": "dimLight", + "title": "Dim light", + "summary": "Command a particular streetlight to dim the lights.", + "traits": [ + { + "$ref": "#/components/messageTraits/commonHeaders" + } + ], + "payload": { + "$ref": "#/components/schemas/dimLightPayload" + } + } + }, + "schemas": { + "lightMeasuredPayload": { + "type": "object", + "properties": { + "lumens": { + "type": "integer", + "minimum": 0, + "description": "Light intensity measured in lumens." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "turnOnOffPayload": { + "type": "object", + "properties": { + "command": { + "type": "string", + "enum": [ + "on", + "off" + ], + "description": "Whether to turn on or off the light." + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "dimLightPayload": { + "type": "object", + "properties": { + "percentage": { + "type": "integer", + "description": "Percentage to which the light should be dimmed to.", + "minimum": 0, + "maximum": 100 + }, + "sentAt": { + "$ref": "#/components/schemas/sentAt" + } + } + }, + "sentAt": { + "type": "string", + "format": "date-time", + "description": "Date and time when the message was sent." + } + }, + "securitySchemes": { + "saslScram": { + "type": "scramSha256", + "description": "Provide your username and password for SASL/SCRAM authentication" + }, + "streetlights_auth": { + "type": "oauth2", + "description": "The oauth security descriptions", + "flows": { + "clientCredentials": { + "tokenUrl": "https://example.com/api/oauth/dialog", + "availableScopes": { + "streetlights:read": "Scope required for subscribing to channel", + "streetlights:write": "Scope required for publishing to channel" + } + } + } + } + }, + "parameters": { + "streetlightId": { + "description": "The ID of the streetlight." + } + }, + "messageTraits": { + "commonHeaders": { + "headers": { + "type": "object", + "properties": { + "my-app-header": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + } + } + } + }, + "operationTraits": { + "kafka": { + "bindings": { + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/complete/websocket-gemini-asyncapi.json b/src/test/resources/fixtures/io/asyncapi/3.0/complete/websocket-gemini-asyncapi.json new file mode 100644 index 00000000..c1b277db --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/complete/websocket-gemini-asyncapi.json @@ -0,0 +1,328 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Gemini Market Data Websocket API", + "version": "1.0.0", + "description": "Market data is a public API that streams all the market data on a given symbol.\n\nYou can quickly play with the API using [websocat](https://github.com/vi/websocat#installation) like this:\n```bash\nwebsocat wss://api.gemini.com/v1/marketdata/btcusd?heartbeat=true -S\n```\n", + "contact": { + "name": "Gemini", + "url": "https://www.gemini.com/" + }, + "externalDocs": { + "url": "https://docs.sandbox.gemini.com/websocket-api/#market-data" + } + }, + "servers": { + "public": { + "host": "api.gemini.com", + "protocol": "wss" + } + }, + "channels": { + "marketDataV1": { + "address": "/v1/marketdata/{symbol}", + "messages": { + "marketData": { + "$ref": "#/components/messages/marketData" + } + }, + "parameters": { + "symbol": { + "enum": [ + "btcusd", + "ethbtc", + "ethusd", + "zecusd", + "zecbtc", + "zeceth", + "zecbch", + "zecltc", + "bchusd", + "bchbtc", + "bcheth", + "ltcusd", + "ltcbtc", + "ltceth", + "ltcbch", + "batusd", + "daiusd", + "linkusd", + "oxtusd", + "batbtc", + "linkbtc", + "oxtbtc", + "bateth", + "linketh", + "oxteth", + "ampusd", + "compusd", + "paxgusd", + "mkrusd", + "zrxusd", + "kncusd", + "manausd", + "storjusd", + "snxusd", + "crvusd", + "balusd", + "uniusd", + "renusd", + "umausd", + "yfiusd", + "btcdai", + "ethdai", + "aaveusd", + "filusd", + "btceur", + "btcgbp", + "etheur", + "ethgbp", + "btcsgd", + "ethsgd", + "sklusd", + "grtusd", + "bntusd", + "1inchusd", + "enjusd", + "lrcusd", + "sandusd", + "cubeusd", + "lptusd", + "bondusd", + "maticusd", + "injusd", + "sushiusd" + ], + "description": "Symbols are formatted as CCY1CCY2 where prices are in CCY2 and quantities are in CCY1. To read more click [here](https://docs.sandbox.gemini.com/websocket-api/#symbols-and-minimums).\n" + } + }, + "bindings": { + "ws": { + "bindingVersion": "0.1.0", + "query": { + "type": "object", + "description": "The semantics of entry type filtering is:\n\nIf any entry type is specified as true or false, all of them must be explicitly flagged true to show up in the response\nIf no entry types filtering parameters are included in the url, then all entry types will appear in the response\n\nNOTE: top_of_book has no meaning and initial book events are empty when only trades is specified\n", + "properties": { + "heartbeat": { + "type": "boolean", + "default": false, + "description": "Optionally add this parameter and set to true to receive a heartbeat every 5 seconds" + }, + "top_of_book": { + "type": "boolean", + "default": false, + "description": "If absent or false, receive full order book depth; if present and true, receive top of book only. Only applies to bids and offers." + }, + "bids": { + "type": "boolean", + "default": true, + "description": "Include bids in change events" + }, + "offers": { + "type": "boolean", + "default": true, + "description": "Include asks in change events" + }, + "trades": { + "type": "boolean", + "default": true, + "description": "Include trade events" + }, + "auctions": { + "type": "boolean", + "default": true, + "description": "Include auction events" + } + } + } + } + } + } + }, + "operations": { + "sendMarketData": { + "action": "send", + "channel": { + "$ref": "#/channels/marketDataV1" + }, + "summary": "Receive market updates on a given symbol", + "messages": [ + { + "$ref": "#/channels/marketDataV1/messages/marketData" + } + ] + } + }, + "components": { + "messages": { + "marketData": { + "summary": "Message with marked data information.", + "description": "The initial response message will show the existing state of the order book. Subsequent messages will show all executed trades, as well as all other changes to the order book from orders placed or canceled.\n", + "payload": { + "$ref": "#/components/schemas/market" + }, + "examples": [ + { + "name": "updateMessage", + "summary": "Example of an update message that contains a change in price information.", + "payload": { + "type": "update", + "eventId": 36902233362, + "timestamp": 1619769673, + "timestampms": 1619769673527, + "socket_sequence": 661, + "events": [ + { + "type": "change", + "side": "bid", + "price": 54350.4, + "remaining": 0.002, + "delta": 0.002, + "reason": "place" + } + ] + } + }, + { + "name": "heartbeatMessage", + "summary": "Example of additional heartbeat message when you enable them.", + "payload": { + "type": "heartbeat", + "socket_sequence": 1656 + } + } + ] + } + }, + "schemas": { + "market": { + "type": "object", + "oneOf": [ + { + "$ref": "#/components/schemas/heartbeat" + }, + { + "$ref": "#/components/schemas/update" + } + ] + }, + "heartbeat": { + "allOf": [ + { + "properties": { + "type": { + "type": "string", + "const": "heartbeat" + } + }, + "required": [ + "type" + ] + }, + { + "$ref": "#/components/schemas/default" + } + ] + }, + "update": { + "allOf": [ + { + "properties": { + "type": { + "type": "string", + "const": "update" + }, + "eventId": { + "type": "integer", + "description": "A monotonically increasing sequence number indicating when this change occurred. These numbers are persistent and consistent between market data connections." + }, + "events": { + "$ref": "#/components/schemas/events" + }, + "timestamp": { + "type": "number", + "description": "The timestamp in seconds for this group of events (included for compatibility reasons). We recommend using the timestampms field instead." + }, + "timestampms": { + "type": "number", + "description": "The timestamp in milliseconds for this group of events." + } + }, + "required": [ + "type", + "eventId", + "events", + "timestamp", + "timestampms" + ] + }, + { + "$ref": "#/components/schemas/default" + } + ] + }, + "default": { + "type": "object", + "description": "This object is always part of the payload. In case of type=heartbeat, these are the only fields.", + "required": [ + "type", + "socket_sequence" + ], + "properties": { + "socket_sequence": { + "type": "integer", + "description": "zero-indexed monotonic increasing sequence number attached to each message sent - if there is a gap in this sequence, you have missed a message. If you choose to enable heartbeats, then heartbeat and update messages will share a single increasing sequence. See [Sequence Numbers](https://docs.sandbox.gemini.com/websocket-api/#sequence-numbers) for more information." + } + } + }, + "events": { + "type": "array", + "description": "Either a change to the order book, or the indication that a trade has occurred.", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "enum": [ + "trade", + "change", + "auction, block_trade" + ] + }, + "price": { + "type": "number", + "multipleOf": 0.01, + "description": "The price of this order book entry." + }, + "side": { + "type": "string", + "enum": [ + "bid", + "side" + ] + }, + "reason": { + "type": "string", + "enum": [ + "place", + "trade", + "cancel", + "initial" + ], + "description": "Indicates why the change has occurred. initial is for the initial response message, which will show the entire existing state of the order book." + }, + "remaining": { + "type": "number", + "description": "The quantity remaining at that price level after this change occurred. May be zero if all orders at this price level have been filled or canceled." + }, + "delta": { + "type": "number", + "description": "The quantity changed. May be negative, if an order is filled or canceled. For initial messages, delta will equal remaining." + } + } + } + } + } + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extensions.json b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extensions.json new file mode 100755 index 00000000..a417ad12 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extensions.json @@ -0,0 +1,16 @@ +{ + "asyncapi" : "3.0.0", + "info" : { + "title": "AsyncAPI 3.0 App", + "description": "This is a very simple AsyncAPI file.", + "version": "1.0.1", + "x-vendor-property-1": "foo-bar", + "x-vendor-property-2": true, + "x-vendor-property-3": { + "sub-property-1": 17, + "sub-property-2": false, + "sub-property-3": "value" + }, + "x-vendor-property-3": 12345 + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extraProperties.json b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extraProperties.json new file mode 100755 index 00000000..b3693177 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info-extraProperties.json @@ -0,0 +1,12 @@ +{ + "asyncapi" : "3.0.0", + "info" : { + "title": "AsyncAPI 3.0 App", + "description": "This is a very simple AsyncAPI file.", + "version": "1.0.1", + "extra-property-1": "value", + "extra-property-2": 17, + "extra-property-3": [ 1, 2, 3, 4 ] + }, + "extra-root-property": true +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info.json b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info.json new file mode 100755 index 00000000..65867d45 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simple-info.json @@ -0,0 +1,8 @@ +{ + "asyncapi" : "3.0.0", + "info" : { + "title": "AsyncAPI 3.0 App", + "description": "This is a very simple AsyncAPI file.", + "version": "1.0.1" + } +} diff --git a/src/test/resources/fixtures/io/asyncapi/3.0/simple/simplest.json b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simplest.json new file mode 100755 index 00000000..b1df8105 --- /dev/null +++ b/src/test/resources/fixtures/io/asyncapi/3.0/simple/simplest.json @@ -0,0 +1,3 @@ +{ + "asyncapi" : "3.0.0" +} diff --git a/src/test/resources/fixtures/io/tests.json b/src/test/resources/fixtures/io/tests.json index 27213940..9a64336f 100755 --- a/src/test/resources/fixtures/io/tests.json +++ b/src/test/resources/fixtures/io/tests.json @@ -4,6 +4,11 @@ { "name": "[AsyncAPI 2] Simple Info With Extra Properties", "test": "asyncapi/2.0/simple/simple-info-extraProperties.json", "extraProperties": 4 }, { "name": "[AsyncAPI 2] Simple Info With Extensions", "test": "asyncapi/2.0/simple/simple-info-extensions.json" }, + { "name": "[AsyncAPI 3] Simplest", "test": "asyncapi/3.0/simple/simplest.json" }, + { "name": "[AsyncAPI 3] Simple Info", "test": "asyncapi/3.0/simple/simple-info.json" }, + { "name": "[AsyncAPI 3] Simple Info With Extra Properties", "test": "asyncapi/3.0/simple/simple-info-extraProperties.json", "extraProperties": 4 }, + { "name": "[AsyncAPI 3] Simple Info With Extensions", "test": "asyncapi/3.0/simple/simple-info-extensions.json" }, + { "name": "[AsyncAPI 2] Complete anyof", "test": "asyncapi/2.0/complete/anyof.json" }, { "name": "[AsyncAPI 2] Complete application-headers", "test": "asyncapi/2.0/complete/application-headers.json" }, { "name": "[AsyncAPI 2] Complete Info", "test": "asyncapi/2.0/complete/complete-info.json" }, @@ -15,7 +20,25 @@ { "name": "[AsyncAPI 2] Complete rpc-server", "test": "asyncapi/2.0/complete/rpc-server.json" }, { "name": "[AsyncAPI 2] Complete slack-rtm", "test": "asyncapi/2.0/complete/slack-rtm.json" }, { "name": "[AsyncAPI 2] Complete streetlights", "test": "asyncapi/2.0/complete/streetlights.json" }, - + + { "name": "[AsyncAPI 3] Adeo Kafka Request", "test": "asyncapi/3.0/complete/adeo-kafka-request-reply-asyncapi.json" }, + { "name": "[AsyncAPI 3] AnyOf", "test": "asyncapi/3.0/complete/anyof-asyncapi.json" }, + { "name": "[AsyncAPI 3] App Headers", "test": "asyncapi/3.0/complete/application-headers-asyncapi.json" }, + { "name": "[AsyncAPI 3] Correlation ID", "test": "asyncapi/3.0/complete/correlation-id-asyncapi.json" }, + { "name": "[AsyncAPI 3] Gitter Streaming", "test": "asyncapi/3.0/complete/gitter-streaming-asyncapi.json" }, + { "name": "[AsyncAPI 3] Mercure", "test": "asyncapi/3.0/complete/mercure-asyncapi.json" }, + { "name": "[AsyncAPI 3] Not", "test": "asyncapi/3.0/complete/not-asyncapi.json" }, + { "name": "[AsyncAPI 3] OneOf", "test": "asyncapi/3.0/complete/oneof-asyncapi.json" }, + { "name": "[AsyncAPI 3] Operation Security", "test": "asyncapi/3.0/complete/operation-security-asyncapi.json" }, + { "name": "[AsyncAPI 3] RPC Client", "test": "asyncapi/3.0/complete/rpc-client-asyncapi.json" }, + { "name": "[AsyncAPI 3] RPC Server", "test": "asyncapi/3.0/complete/rpc-server-asyncapi.json" }, + { "name": "[AsyncAPI 3] Simple", "test": "asyncapi/3.0/complete/simple-asyncapi.json" }, + { "name": "[AsyncAPI 3] Slack RTM", "test": "asyncapi/3.0/complete/slack-rtm-asyncapi.json" }, + { "name": "[AsyncAPI 3] Streetlights Kafka", "test": "asyncapi/3.0/complete/streetlights-kafka-asyncapi.json" }, + { "name": "[AsyncAPI 3] Streetlights MQTT", "test": "asyncapi/3.0/complete/streetlights-mqtt-asyncapi.json" }, + { "name": "[AsyncAPI 3] Streetlights OpSec", "test": "asyncapi/3.0/complete/streetlights-operation-security-asyncapi.json" }, + { "name": "[AsyncAPI 3] Websocket Gemini", "test": "asyncapi/3.0/complete/websocket-gemini-asyncapi.json" }, + { "name": "[OpenAPI 2] Simple - External Docs", "test": "openapi/2.0/simple/simple-externalDocs.json" }, { "name": "[OpenAPI 2] Simple - Info + Extensions", "test": "openapi/2.0/simple/simple-info-extensions.json" }, { "name": "[OpenAPI 2] Simple - Info", "test": "openapi/2.0/simple/simple-info.json" },