Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate few spec breaking changes as acceptance criteria for the new Parser API #93

Closed
smoya opened this issue Mar 17, 2021 · 7 comments
Assignees
Labels
Epic Scope Scopes are groups of related tasks.

Comments

@smoya
Copy link
Member

smoya commented Mar 17, 2021

Emulating new spec major versions that introduce breaking changes will help us for:

By emulating I mean just creating few spec documents where concepts are changed, such as split Operations, renaming fields, changing the deep level of some objects, reorder them, etc.

The outcome of this issue is a collection of either yaml or JsonSchema documents that introduce breaking changes.
They can be written here as a reference by now.

@smoya smoya added Scope Scopes are groups of related tasks. Epic labels Mar 17, 2021
@smoya smoya self-assigned this Mar 17, 2021
@asyncapi-bot
Copy link

Hey! You've labeled this issue as a Scope. Remember you can use the following command to inform about its progress:

/progress <percentage> [message]

or

/progress <percentage>

A mutiline message.
It supports **Markdown**.
Example:
/progress 40 We're still figuring out how to implement this. We have an idea but it is not yet confirmed it will work.
/progress 50

A few notes:

* We got this figured out :tada:
* We're going to use [this library](#link-to-website) to avoid losing time implementing this algorithm.
* We decided to go for the quickest solution and will improve it if we got time at the end of the cycle.

🏋️‍♀️ See the progress on the Shape Up Dashboard.

@smoya
Copy link
Member Author

smoya commented Mar 17, 2021

Based on #73, and modifying a bit the StreetLights tutorial example, I emulated a possible breaking change on channels:

Current version:

asyncapi: '2.0.0'
info:
  title: Streetlights API
  version: '1.0.0'
  description: |
    The Smartylighting Streetlights API allows you
    to remotely manage the city lights.
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0'
servers:
  mosquitto:
    url: mqtt://test.mosquitto.org
    protocol: mqtt
channels:
  light/measured:
    publish:
      summary: Inform about environmental lighting conditions for a particular streetlight.
      operationId: onLightMeasured
      message:
        payload:
          type: object
          properties:
            id:
              type: integer
              minimum: 0
              description: Id of the streetlight.
            lumens:
              type: integer
              minimum: 0
              description: Light intensity measured in lumens.
            sentAt:
              type: string
              format: date-time
              description: Date and time when the message was sent.
  light/measured/changed:
    subscribe:
      summary: Receive an update every time a lighting condition changed.
      operationId: onLightMeasureChanged
      message:
        payload:
          type: object
          properties:
            id:
              type: integer
              minimum: 0
              description: Id of the streetlight.
            lumens:
              type: integer
              minimum: 0
              description: Light intensity measured in lumens.
            sentAt:
              type: string
              format: date-time
              description: Date and time when the message was sent.

New version:

asyncapi: '3.0.0-fake'
# ...
channels:
  light/measured:
    summary: Environmental lighting conditions for a particular streetlight
    operations: 
      # this could be a new component that could be referenced by #/components/operations/onLightMeasured
      onLightMeasured: 
        $ref: "#/components/messages/lightMeasured"
        operationType: publish
        summary: Inform about environmental lighting conditions for a particular streetlight.
 
     # this could be a new component that could be referenced by #/components/operations/onLightMeasureChanged
      onLightMeasureChanged: 
        $ref: "#/components/messages/lightMeasured"
        operationType: subscribe
        summary: Receive an update every time a lighting condition changed.
components:
   messages:
    lightMeasured:
      message:
        payload:
          type: object
          properties:
            id:
              type: integer
              minimum: 0
              description: Id of the streetlight.
            lumens:
              type: integer
              minimum: 0
              description: Light intensity measured in lumens.
            sentAt:
              type: string
              format: date-time
              description: Date and time when the message was sent.

@smoya
Copy link
Member Author

smoya commented Mar 17, 2021

/progress 25 Emulated breaking change based on #73

@smoya
Copy link
Member Author

smoya commented Mar 18, 2021

Another emualted version based on asyncapi/spec#434 supporting multiple message schemaFormat values.

asyncapi: '3.0.0-fake2'
# ...
channels:
  light/measured:
    publish:
      summary: Inform about environmental lighting conditions for a particular streetlight.
      operationId: onLightMeasured
      message:
        schemaFormat: 
         oneOf:
            - "application/vnd.apache.avro+json;version=1.9.0"
            - "application/vnd.oai.openapi;version=3.0.0"
        payload:
          type: object
          properties:
            id:
              type: integer
              minimum: 0
              description: Id of the streetlight.
            lumens:
              type: integer
              minimum: 0
              description: Light intensity measured in lumens.
            sentAt:
              type: string
              format: date-time
              description: Date and time when the message was sent.

@smoya
Copy link
Member Author

smoya commented Mar 18, 2021

/progress 65 Emulated breaking change based on asyncapi/spec#434

@smoya
Copy link
Member Author

smoya commented Mar 22, 2021

Taking a couple of new approaches based on #73:

1. Messages flow within a channel (still) through operations, but objects are decoupled.

asyncapi: '3.0.0-fake3'
# ...
channels:
  light/measured:
    summary: Lighting conditions for a particular streetlight.
operations:
  onLightMeasured:
    operationType: publish
    summary: Inform about environmental lighting conditions for a particular streetlight.
    withMessage: lightMeasured
    withinChannel: light/measured
  onLightMeasureChanged:
    operationType: subscribe
    summary: Receive an update every time a lighting condition changed.
    withMessage: lightMeasured
    withinChannel: light/measured
messages:
  lightMeasured:
    payload:
      type: object
      properties:
        id:
          type: integer
          minimum: 0
          description: Id of the streetlight.
        lumens:
          type: integer
          minimum: 0
          description: Light intensity measured in lumens.
        sentAt:
          type: string
          format: date-time
          description: Date and time when the message was sent.

2. Messages are independent of channels. Messages within a channel can (optionally) be related to operations. Compatible with asyncapi/parser-js#210

asyncapi: '3.0.0-fake4'
# ...
channels:
  light/measured:
    summary: Lighting conditions for a particular streetlight.
    messages:
      - message: lightMeasured # this should exist in `messages`
        operations: 
          onLightMeasured:
            operationType: publish
            summary: Inform about environmental lighting conditions for a particular streetlight.
          onLightMeasureChanged:
            operationType: subscribe
            summary: Receive an update every time a lighting condition changed.
messages:
  lightMeasured:
    payload:
      type: object
      properties:
        id:
          type: integer
          minimum: 0
          description: Id of the streetlight.
        lumens:
          type: integer
          minimum: 0
          description: Light intensity measured in lumens.
        sentAt:
          type: string
          format: date-time
          description: Date and time when the message was sent.

@smoya
Copy link
Member Author

smoya commented Mar 23, 2021

/progress 100 Emulated 2 new breaking changes. One based on #73 and another one based on asyncapi/parser-js#210.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Scope Scopes are groups of related tasks.
Projects
None yet
Development

No branches or pull requests

2 participants