spec icon indicating copy to clipboard operation
spec copied to clipboard

`example` is used for example for Schema Object examples (instead of `examples`)

Open aborg0 opened this issue 4 years ago • 3 comments

Describe the bug

At Schema Object examples Model with Example the examples (JSON and also the YAML) use example, but the previous part of the specification suggests that examples can be used. The tooling seems to support examples, but not example. Discussion: https://asyncapi.slack.com/archives/CQVJXFNQL/p1642787250166800

To Reproduce

Steps to reproduce the behavior:

  1. Create a document with example.
  2. Try to change to 'examples' and make it a list.
  3. Try to validate the document doing 'studio' for example
  4. The studio does not render the example, but it does the examples

Expected behavior

I expect to support examples (/), and at least does not provide an example with example, maybe that can be disallowed in the spec too to avoid confusion (though that can be hard to defend as the schema can have extra keys).

Sample document

Example fragmentss I think we should not have:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "name"
  ],
  "example": {
    "name": "Puma",
    "id": 1
  }
}
type: object
properties:
  id:
    type: integer
    format: int64
  name:
    type: string
required:
- name
example:
  name: Puma
  id: 1

Proper example fragments should look like this in my opinion:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "name"
  ],
  "examples": [
     {
       "name": "Puma",
       "id": 1
     }
  ]
}
type: object
properties:
  id:
    type: integer
    format: int64
  name:
    type: string
required:
- name
examples:
  -
    name: Puma
    id: 1

aborg0 avatar Jan 21 '22 21:01 aborg0

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

github-actions[bot] avatar Jan 21 '22 21:01 github-actions[bot]

oh this is weird that nobody yet noticed it 🤔 even though I think I had a related discussion with someone some day 😅

thanks a lot, feel free to open a PR to adjust it there in the spec 🙏🏼

derberg avatar Jan 24 '22 09:01 derberg

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar May 25 '22 00:05 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Nov 27 '22 00:11 github-actions[bot]