diff --git a/components/Message.js b/components/Message.js index 8c73e573f..370ab58e9 100644 --- a/components/Message.js +++ b/components/Message.js @@ -13,8 +13,7 @@ export function Message({ message }) { // NOSONAR return null; } - // check typeof as fallback for older version than `2.4.0` - const messageId = typeof message.messageId === 'function' && message.messageId(); + const messageId = message.id(); const headers = message.headers(); const payload = message.payload(); const correlationId = message.correlationId(); @@ -26,7 +25,7 @@ export function Message({ message }) { // NOSONAR if (message.title()) { header += ` ${message.title()}`; } - const id = message.messageId() || message.name() || message.id(); + const id = message.name() || messageId; if (id) { header += ` \`${id}\``; } diff --git a/package-lock.json b/package-lock.json index 884d467b9..a5d0667fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ }, "devDependencies": { "@asyncapi/cli": "^0.60.1", - "@asyncapi/parser": "^3.0.0-next-major-spec.3", + "@asyncapi/parser": "^3.0.0-next-major-spec.11", "@babel/preset-env": "^7.15.8", "@babel/preset-react": "^7.14.5", "@types/react": "^18.2.18", @@ -1444,12 +1444,12 @@ } }, "node_modules/@asyncapi/parser": { - "version": "3.0.0-next-major-spec.3", - "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.0-next-major-spec.3.tgz", - "integrity": "sha512-LCrAQqJpGxraMyU2k1Nh1X6Q1dz7a/YhTRRFFrQHOEo+TUT/kRdoUkRDP++e58dO7h9MBN+/hZK5TaqE+/jQiw==", + "version": "3.0.0-next-major-spec.11", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.0-next-major-spec.11.tgz", + "integrity": "sha512-jJX2HGmeXykvJ1KfrYadeYbf0Dh4mDDvD5KNtf/SJGvVANdYRQrgCV14VlBMnv7kPVELuv8JaYEedYe6x4F8zA==", "dev": true, "dependencies": { - "@asyncapi/specs": "^6.0.0-next-major-spec.6", + "@asyncapi/specs": "^6.0.0-next-major-spec.9", "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", "@stoplight/json-ref-resolver": "^3.1.5", "@stoplight/spectral-core": "^1.16.1", @@ -1740,9 +1740,9 @@ } }, "node_modules/@asyncapi/specs": { - "version": "6.0.0-next-major-spec.6", - "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.6.tgz", - "integrity": "sha512-xYiXZetKiAZgZoh2q/sxt+Ceg8bLTK/WSCwtLvlH7JgnjpnOEtCDwKszijmmOJEYdGVSrj0OFXLPrg/dm4JANw==", + "version": "6.0.0-next-major-spec.13", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.13.tgz", + "integrity": "sha512-mnGllHVaUscCHaDnYfLGo84KK81NcTmevVFQP94RusKM2SvtYkbBuC0nwQ6ie/PAEHQy+kn2PjrJlfwwm7VgEQ==", "dev": true, "dependencies": { "@types/json-schema": "^7.0.11" diff --git a/package.json b/package.json index db62fb916..15a4760df 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@asyncapi/cli": "^0.60.1", - "@asyncapi/parser": "^3.0.0-next-major-spec.3", + "@asyncapi/parser": "^3.0.0-next-major-spec.11", "@babel/preset-env": "^7.15.8", "@babel/preset-react": "^7.14.5", "@types/react": "^18.2.18", diff --git a/test/components/Message.test.js b/test/components/Message.test.js index 8ee80f890..52ff93b25 100644 --- a/test/components/Message.test.js +++ b/test/components/Message.test.js @@ -138,9 +138,9 @@ describe('Message component', () => { } } ] - }); + }, { id: 'UserSignup Message Id' }); const expected = ` -#### Message User signup \`UserSignup Message Id\` +#### Message User signup \`UserSignup\` *Action to sign a user up.* diff --git a/test/components/Operations.test.js b/test/components/Operations.test.js index bf01e7113..dc41d64c8 100644 --- a/test/components/Operations.test.js +++ b/test/components/Operations.test.js @@ -918,7 +918,6 @@ A longer description of the message } }, SomeMessage2: { - messageId: 'SomeMessage2', description: 'A longer description of the message', payload: { type: 'object', diff --git a/test/components/__snapshots__/AsyncAPI.test.js.snap b/test/components/__snapshots__/AsyncAPI.test.js.snap index d9b93f70e..5bd5e30b8 100644 --- a/test/components/__snapshots__/AsyncAPI.test.js.snap +++ b/test/components/__snapshots__/AsyncAPI.test.js.snap @@ -360,297 +360,92 @@ Accepts **one of** the following messages: `; exports[`AsyncAPI component should render AsyncAPI v3 document 1`] = ` -"# Adeo AsyncAPI Case Study %REPLACED_BY_MAVEN% documentation +"# Streetlights API 1.0.0 documentation -* Email support: [info@asyncapi.io](mailto:info@asyncapi.io) +* License: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) +* Default content type: [application/json](https://www.iana.org/assignments/media-types/application/json) -This Adeo specification illustrates how ADEO uses AsyncAPI to document some of their exchanges +The Smartylighting Streetlights API allows you to remotely manage the city lights. -##### Specification tags +### Check out its awesome features: -| Name | Description | Documentation | -|---|---|---| -| costing | Costing channels, used by Costing clients. | - | +* Turn a specific streetlight on/off 🌃 +* Dim a specific streetlight 😎 +* Receive real-time information about environmental lighting conditions 📈 ## Table of Contents * [Servers](#servers) * [production](#production-server) - * [staging](#staging-server) - * [dev](#dev-server) ## Servers ### \`production\` Server -* URL: \`kafka-secure://prod.url:9092/\` -* Protocol: \`kafka-secure\` - -Kafka PRODUCTION cluster - -#### Security - -##### Security Requirement 1 - -* Type: \`PLAIN\` - * security.protocol: SASL_SSL - * sasl.mechanism: PLAIN - - Use [SASL authentication with SSL encryption](https://docs.confluent.io/platform/current/security/security_tutorial.html#configure-clients) to connect to the ADEO Broker. - - - - - - -#### \`kafka\` Server specific information - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| schemaRegistryUrl | - | - | \`\\"https://schema-registry.prod.url/\\"\` | - | - | - - -### \`staging\` Server - -* URL: \`kafka-secure://staging.url:9092/\` -* Protocol: \`kafka-secure\` - -Kafka STAGING cluster for \`uat\` and \`preprod\` environments - -#### Security - -##### Security Requirement 1 - -* Type: \`PLAIN\` - * security.protocol: SASL_SSL - * sasl.mechanism: PLAIN - - Use [SASL authentication with SSL encryption](https://docs.confluent.io/platform/current/security/security_tutorial.html#configure-clients) to connect to the ADEO Broker. - - - - - - -#### \`kafka\` Server specific information - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| schemaRegistryUrl | - | - | \`\\"https://schema-registry.staging.url/\\"\` | - | - | - - -### \`dev\` Server - -* URL: \`kafka-secure://dev.url:9092/\` -* Protocol: \`kafka-secure\` - -Kafka DEV cluster for \`dev\` and \`sit\` environments - -#### Security - -##### Security Requirement 1 - -* Type: \`PLAIN\` - * security.protocol: SASL_SSL - * sasl.mechanism: PLAIN - - Use [SASL authentication with SSL encryption](https://docs.confluent.io/platform/current/security/security_tutorial.html#configure-clients) to connect to the ADEO Broker. - - - - +* URL: \`mqtt://test.mosquitto.org:{port}/\` +* Protocol: \`mqtt\` +Test broker -#### \`kafka\` Server specific information +#### URL Variables -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| schemaRegistryUrl | - | - | \`\\"https://schema-registry.dev.url/\\"\` | - | - | +| Name | Description | Default value | Allowed values | +|---|---|---|---| +| port | Secure connection (TLS) is available through port 8883. | \`1883\` | \`1883\`, \`8883\` | ## Operations -### REPLY \`adeo-{env}-case-study-COSTING-REQUEST-{version}\` Operation - -*[COSTING] Request one or more Costing calculation for any product* - -* Operation ID: \`requestCosting\` - -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 \`x-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) - - -You can try a costing request using our [Conduktor producer template](https://conduktor.url) +### SEND \`some.channel\` Operation +* Operation ID: \`some.channel.subscribe\` -##### Operation tags - -| Name | Description | Documentation | -|---|---|---| -| costing | - | - | - -#### Parameters - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| env | string | Adeo Kafka Environment for messages publications. | allowed (\`\\"dev\\"\`, \`\\"sit\\"\`, \`\\"uat1\\"\`, \`\\"preprod\\"\`, \`\\"prod\\"\`) | - | **required** | -| version | string | the topic version you want to use | default (\`\\"V1\\"\`), examples (\`\\"V1\\"\`) | - | **required** | - - -#### \`kafka\` Channel specific information - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| replicas | - | - | \`\\"3\\"\` | - | - | -| partitions | - | - | \`\\"3\\"\` | - | - | -| topicConfiguration | - | - | - | - | - | -| topicConfiguration.cleanup.policy | - | - | - | - | - | -| topicConfiguration.cleanup.policy.0 (index) | - | - | \`\\"delete\\"\` | - | - | -| topicConfiguration.retention.ms | - | - | \`\\"604800000\\"\` | - | - | +this description shows in markdown -#### \`kafka\` Operation specific information +Sending **one of** the following messages: -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| groupId | string | 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. | - | - | - | -| x-value.subject.name.strategy | string | We use the RecordNameStrategy to infer the messages schema. Use \`x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy\` in your producer configuration. | - | - | - | - -#### Message Costing Request V1 \`CostingRequestV1\` +#### Message \`Success\` -*Costing Request V1 inputs.* +* Content type: [application/json](https://www.iana.org/assignments/media-types/application/json) -##### Headers +##### Payload | Name | Type | Description | Value | Constraints | Notes | |---|---|---|---|---|---| | (root) | object | - | - | - | **additional properties are allowed** | -| REQUEST_ID | string | A unique Request ID needed to define a \`CORRELATION_ID\` for exchanges, which will be sent back in the Costing Responses. | - | format (\`uuid\`) | **required** | -| REPLY_TOPIC | string | 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.** | - | - | **required** | -| REQUESTER_ID | string | The Costing requester service account used to produce costing request. | - | - | **required** | -| REQUESTER_CODE | string | The Costing requester code (generally the BU Code). The requester code is useful to get the dedicated context (tenant). | - | - | **required** | +| result | string | - | examples (\`\\"success\\"\`) | - | - | -> Examples of headers _(generated)_ +> Examples of payload _(generated)_ \`\`\`json { - \\"REQUEST_ID\\": \\"1fa6ef40-8f47-40a8-8cf6-f8607d0066ef\\", - \\"REPLY_TOPIC\\": \\"adeo-case-study-COSTING-RESPONSE-V1\\", - \\"REQUESTER_ID\\": \\"svc-ecollect-app\\", - \\"REQUESTER_CODE\\": 1 + \\"result\\": \\"success\\" } \`\`\` -##### Payload - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| (root) | record | - | - | - | - | - -> Examples of payload _(generated)_ - -\`\`\`json -\\"\\" -\`\`\` - - -##### Message tags - -| Name | Description | Documentation | -|---|---|---| -| costing | - | - | - -#### Response information - -* should be done to channel: \`adeo-{env}-case-study-COSTING-RESPONSE-{version}\` -#### Operation reply address information - -* Operation reply address location: \`$message.header#/REPLY_TOPIC\` - - - -### SEND \`adeo-{env}-case-study-COSTING-RESPONSE-{version}\` Operation - -*[COSTING] Get the costing responses matching an initial Costing Request.* - -* Operation ID: \`getCostingResponse\` - -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. You have to define \`key.subject.name.strategy\` and \`x-value.subject.name.strategy\` to \`io.confluent.kafka.serializers.subject.RecordNameStrategy\` in your consumer. The schema below illustrates how Costing Response messages are handled. - ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png) - - -##### Operation tags - -| Name | Description | Documentation | -|---|---|---| -| costing | - | - | - -#### Parameters - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| env | string | Adeo Kafka Environment for messages publications. | allowed (\`\\"dev\\"\`, \`\\"sit\\"\`, \`\\"uat1\\"\`, \`\\"preprod\\"\`, \`\\"prod\\"\`) | - | **required** | -| version | string | the topic version you want to use | default (\`\\"V1\\"\`), examples (\`\\"V1\\"\`) | - | **required** | - - -#### \`kafka\` Channel specific information - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| x-key.subject.name.strategy | string | We use the RecordNameStrategy to infer the messages schema. Use \`x-key.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy\` in your consumer configuration. | - | - | - | -| x-value.subject.name.strategy | string | We use the RecordNameStrategy to infer the messages schema. Use \`x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy\` in your consumer configuration. | - | - | - | - -#### \`kafka\` Operation specific information - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| groupId | string | The groupId must be prefixed by your \`svc\` account, deliver by the Adeo Kafka team. This \`svc\` must have the read access to the topic. | - | - | - | - -#### Message Costing Response \`CostingResponse\` - -*Costing Response ouputs.* - -Please refer to the \`CostingResponseKey.avsc\` schema, available on [our github project](https://github.url/). +#### Message \`Failure\` +* Content type: [application/json](https://www.iana.org/assignments/media-types/application/json) -##### Headers +##### Payload | Name | Type | Description | Value | Constraints | Notes | |---|---|---|---|---|---| -| (root) | object | - | - | - | **additional properties are allowed** | -| CALCULATION_ID | string | A unique Message ID. | - | format (\`uuid\`) | - | -| CORRELATION_ID | string | A unique Correlation ID defined from the \`REQUEST_ID\` or the \`MESSAGE_ID\` provided in the Costing Request. | - | format (\`uuid\`) | - | -| REQUEST_TIMESTAMP | string | Timestamp of the costing request | - | format (\`date-time\`) | - | -| CALCULATION_TIMESTAMP | string | Technical timestamp for the costing calculation | - | format (\`date-time\`) | - | +| (root) | object | - | examples (\`{\\"error\\":{\\"errorCode\\":404,\\"errorMessage\\":\\"Something messed up\\"}}\`) | - | **additional properties are allowed** | +| error | object | - | - | - | **additional properties are allowed** | +| error.errorCode | integer | - | - | - | - | +| error.errorMessage | string | - | - | - | - | -> Examples of headers _(generated)_ +> Examples of payload \`\`\`json { - \\"CALCULATION_ID\\": \\"1fa6ef40-8f47-40a8-8cf6-f8607d0066ef\\", - \\"CORRELATION_ID\\": \\"1fa6ef40-8f47-40a8-8cf6-f8607d0066ef\\", - \\"REQUEST_TIMESTAMP\\": \\"2019-08-24T14:15:22Z\\", - \\"CALCULATION_TIMESTAMP\\": \\"2019-08-24T14:15:22Z\\" + \\"error\\": { + \\"errorCode\\": 404, + \\"errorMessage\\": \\"Something messed up\\" + } } -\`\`\` - - -##### Payload - -| Name | Type | Description | Value | Constraints | Notes | -|---|---|---|---|---|---| -| (root) | record | - | - | - | - | - -> Examples of payload _(generated)_ - -\`\`\`json -\\"\\" -\`\`\` - - -##### Message tags - -| Name | Description | Documentation | -|---|---|---| -| costing | - | - |" +\`\`\`" `; diff --git a/test/spec/asyncapi_v3.yml b/test/spec/asyncapi_v3.yml index 06e285bef..c5639d710 100644 --- a/test/spec/asyncapi_v3.yml +++ b/test/spec/asyncapi_v3.yml @@ -1,318 +1,291 @@ 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 - contact: - name: AsyncAPI team - email: info@asyncapi.io - tags: - - name: costing - description: "Costing channels, used by Costing clients." + title: Streetlights 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 \U0001F303\n* Dim a specific streetlight \U0001F60E\n* Receive real-time information about environmental lighting conditions \U0001F4C8\n" + license: + name: Apache 2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0' +defaultContentType: application/json servers: production: - host: "prod.url:9092" - protocol: kafka-secure - 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-secure - description: Kafka STAGING cluster for `uat` and `preprod` environments - security: - - $ref: '#/components/securitySchemes/sasl-ssl' - bindings: - kafka: - schemaRegistryUrl: >- - https://schema-registry.staging.url/ - dev: - host: "dev.url:9092" - protocol: kafka-secure - description: Kafka DEV cluster for `dev` and `sit` environments - security: - - $ref: '#/components/securitySchemes/sasl-ssl' - bindings: - kafka: - schemaRegistryUrl: >- - https://schema-registry.dev.url/ - + 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: - costingRequest: - 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 `x-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) + 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured': + address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' + messages: + receiveLightMeasurement.message: + $ref: '#/components/messages/lightMeasured' + description: The topic on which measured values may be produced and consumed. parameters: - env: - $ref: "#/components/parameters/Env" - version: - $ref: "#/components/parameters/Version" - bindings: - kafka: - replicas: 3 - partitions: 3 - topicConfiguration: - cleanup.policy: [ "delete" ] - retention.ms: 604800000 + streetlightId: + $ref: '#/components/parameters/streetlightId' + 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on': + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' messages: - costingRequest: - $ref: "#/components/messages/costingRequestV1" - - costingResponse: - address: "adeo-{env}-case-study-COSTING-RESPONSE-{version}" - 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. - You have to define `key.subject.name.strategy` and - `x-value.subject.name.strategy` to - `io.confluent.kafka.serializers.subject.RecordNameStrategy` in your - consumer. - The schema below illustrates how Costing Response messages are - handled. - ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png) + turnOn.message: + $ref: '#/components/messages/turnOnOff' parameters: - env: - $ref: "#/components/parameters/Env" - version: - $ref: "#/components/parameters/Version" - bindings: - kafka: - x-key.subject.name.strategy: - type: string - description: > - We use the RecordNameStrategy to infer the messages schema. - Use - `x-key.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` - in your consumer configuration. - x-value.subject.name.strategy: - type: string - description: > - We use the RecordNameStrategy to infer the messages schema. - Use - `x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` - in your consumer configuration. + streetlightId: + $ref: '#/components/parameters/streetlightId' + 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off': + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off' messages: - costingResponse: - $ref: "#/components/messages/costingResponse" - + turnOff.message: + $ref: '#/components/messages/turnOnOff' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + 'smartylighting/streetlights/1/0/action/{streetlightId}/dim': + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim' + messages: + dimLight.message: + $ref: '#/components/messages/dimLight' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + some.channel: + address: some.channel + messages: + subscribe.message.0: + $ref: '#/components/messages/successMessage' + subscribe.message.1: + $ref: '#/components/messages/failureMessage' operations: - requestCosting: - action: receive - channel: - $ref: '#/channels/costingRequest' - reply: - channel: - $ref: '#/channels/costingResponse' - address: - location: '$message.header#/REPLY_TOPIC' - summary: | - [COSTING] Request one or more Costing calculation for any product - description: > - You can try a costing request using our [Conduktor producer - template](https://conduktor.url) - 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. - x-value.subject.name.strategy: - type: string - description: > - We use the RecordNameStrategy to infer the messages schema. - Use - `x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` - in your producer configuration. - getCostingResponse: - action: send - channel: - $ref: '#/channels/costingResponse' - summary: > - [COSTING] Get the costing responses matching an initial Costing - Request. - 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 read access to the topic. - tags: - - name: costing + receiveLightMeasurement: + action: receive + channel: + $ref: >- + #/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + description: | + This is the description with **bold** text. + On multiple lines. + tags: + - name: oparation-tag1 + externalDocs: + description: External docs description 1 + url: 'https://www.asyncapi.com/' + - name: oparation-tag2 + description: Description 2 + externalDocs: + url: 'https://www.asyncapi.com/' + - name: oparation-tag3 + - name: oparation-tag4 + description: Description 4 + - name: message-tag5 + externalDocs: + url: 'https://www.asyncapi.com/' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/lightMeasured' + turnOn: + action: send + channel: + $ref: >- + #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/turnOnOff' + turnOff: + action: send + channel: + $ref: >- + #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1off + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/turnOnOff' + dimLight: + action: send + channel: + $ref: >- + #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1dim + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/dimLight' + some.channel.subscribe: + action: send + channel: + $ref: '#/channels/some.channel' + description: this description shows in markdown + messages: + - $ref: '#/components/messages/successMessage' + - $ref: '#/components/messages/failureMessage' 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. - location: $message.header#/REQUEST_ID messages: - costingRequestV1: - name: CostingRequestV1 - title: Costing Request V1 - summary: Costing Request V1 inputs. + lightMeasured: + name: lightMeasured + title: Light measured + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + contentType: application/json 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" + - name: message-tag1 + externalDocs: + description: External docs description 1 + url: 'https://www.asyncapi.com/' + - name: message-tag2 + description: Description 2 + externalDocs: + url: 'https://www.asyncapi.com/' + - name: message-tag3 + - name: message-tag4 + description: Description 4 + - name: message-tag5 + externalDocs: + url: 'https://www.asyncapi.com/' + 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' + successMessage: + name: Success 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/). - 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: + result: type: string - format: date-time - description: Technical timestamp for the costing calculation + examples: + - success + failureMessage: + name: Failure payload: - schemaFormat: application/vnd.apache.avro;version=1.9.0 - schema: - $ref: "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingResponsePayload.avsc" + type: object + properties: + error: + type: object + properties: + errorCode: + type: integer + errorMessage: + type: string + examples: + - error: + errorCode: 404 + errorMessage: Something messed up schemas: - RequesterId: - type: string - description: The Costing requester service account used to produce costing request. - example: 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). - example: 1 - MessageId: - type: string - format: uuid - description: A unique Message ID. - example: 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. - example: 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. - example: 1fa6ef40-8f47-40a8-8cf6-f8607d0066ef - BuCode: - type: string - description: The Business Unit code for which data are applicable. - example: 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.** - example: adeo-case-study-COSTING-RESPONSE-V1 - ErrorStep: - type: string - description: | - The woker that has thrown the error. - example: EXPOSE_RESULT - ErrorMessage: - type: string - description: | - The error message describing the error. - example: Error message - ErrorCode: + lightMeasuredPayload: + type: object + properties: + lumens: + type: integer + minimum: 0 + description: Light intensity measured in lumens. + x-pi: false + sentAt: + $ref: '#/components/schemas/sentAt' + turnOnOffPayload: + type: object + properties: + command: + type: string + enum: + - 'on' + - 'off' + description: Whether to turn on or off the light. + x-pi: false + 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 - description: | - The error code. - example: CURRENCY_NOT_FOUND - parameters: - Env: - description: Adeo Kafka Environment for messages publications. - enum: - - dev - - sit - - uat1 - - preprod - - prod - Version: - description: the topic version you want to use - examples: - - V1 - default: V1 + format: date-time + description: Date and time when the message was sent. 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. \ No newline at end of file + 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: + kafka: + bindings: + kafka: + clientId: + const: my-app-id