Closed nilkanth987 closed 5 months ago
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.
Update: If I comment the examples
then it works. I think the examples
parsing is causing issues.
You cannot use references for values in examples i.e. this is not valid:
examples:
- location:
from:
$ref: "#/components/schemas/location/examples/0"
to:
$ref: "#/components/schemas
You have to use static values 🙂
@jonaslagoni , Its very cumbersome to write same examples again. Also the asyncapi
extension in the VS code accepts the code and displays properly.
Its working when I reference an object 1 time in the example but only when I reference the object twice in the examples it throws error.
Then the extension is bugged, it does not validate before resolving references.
I would highly recommend you to create a feature request in the spec 😄 Its not the first time hearing this use case, so its good one 👍
@jonaslagoni , I created a feature request, check and let me know if something is missing. Should I close this issue?
As its not an issue with Modelina but the spec itself, yes please do 🙂
@jonaslagoni , I checked by replacing the references with static values but it still gives me error. Here is the example
asyncapi: 2.6.0
info:
title: Test API
version: 0.0.21
defaultContentType: application/json
channels:
/test:
publish:
message:
$ref: "#/components/messages/testMessage"
components:
messages:
testMessage:
name: testMessage
payload:
type: object
$id: testMessage
properties:
location:
type: object
properties:
from:
$ref: "#/components/schemas/location"
to:
$ref: "#/components/schemas/location"
examples:
- location:
from:
lat: 101
lng: 102
to:
lat: 101
lng: 102
schemas:
location:
type: object
$id: location
properties:
lat:
type: number
lng:
type: number
examples:
- lat: 101
lng: 102
Here I have replaced the references in examples with the static values and I receive the below error
Input is not a correct AsyncAPI document so it cannot be processed.
asyncapi.yml
27:13 error asyncapi2-schema-examples reference "location" resolves to more than one schema components.messages.testMessage.payload.examples[0]
44:11 error asyncapi2-schema-examples schema with key or id "location" already exists components.schemas.location.examples[0]
If I remove the examples from location schema then only 1 error comes
Input is not a correct AsyncAPI document so it cannot be processed.
asyncapi.yml
27:13 error asyncapi2-schema-examples reference "location" resolves to more than one schema components.messages.testMessage.payload.examples[0]
I think there is some bug in example validation which throws error when the schema1 has multiple references to schema2. Let me know if you need more clarification.
Yep, but it's parser related 🙂 Moving the issue
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.
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:
Describe the bug
Referencing same object multiple times in the message with
$id
in the referencing object causing issue.How to Reproduce
When you run the below cmd
It produces the below output
_NOTE : When you remove
$id
fromlocation
schema it works but it will create model withAnonymousSchema_1
name._Expected behavior
It should ignore the previous id and override the object