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
[BUG] Endpoints examples ignored at AsyncAPI docs generation. #933
Comments
@strobe can you look at the PR #973? It should fix the problem - examples where indeed ignored. To support them, I've added However, when I paste the generated YAML into the async api playground (https://playground.asyncapi.io/), I get verification errors. I think this must be a problem with the playground, though, as as far as I can see the generated yaml matches the spec. |
@adamw thanks, I will try to test that in the next 2 days and will write feedback here.
seems I got those with previous versions too (with v0.17.1) |
Fix #933: add example support to AsyncAPI
This is now released in 0.17.8 - let me know how it works :) |
I tested it - works for me. @adamw Regarding those "async api playground" errors I found that at least one problem is related to wrong indentation on 'examples' and 'contentType'. as result of docs generation I getting something like this:
but it should be:
|
actually not sure, seems the spec doesn't has much info about this. Only one example from spec that suitable looks like:
'example' here at same level as 'properties' |
According to: https://www.asyncapi.com/docs/specifications/2.0.0#messageObject, However, schemas can also have examples (https://www.asyncapi.com/docs/specifications/2.0.0#schemaObject, https://github.com/softwaremill/tapir/blob/master/apispec/apispec-model/src/main/scala/sttp/tapir/apispec/Schema.scala#L19). These could be two different examples. Currently tapir doesn't support schema-level examples, though we probably will in the future, when we add an example to tapir's The reason for this separation is probably that a single schema can be used in different contexts (e.g. as part of different messages), so you might want to both provide example for the individual building blocks, as well as for the whole message. |
thanks for the clarification, seems it's asyncAPI a parser issue. |
@adamw Documentation on the AsyncApi website little outdated and the new version is here https://github.com/asyncapi/asyncapi/blob/master/versions/2.0.0/asyncapi.md#messageObject So seems the correct way to specify examples on message object is: components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the use
examples:
- payload:
- displayName: "name1"
email: "email1@example.com"
- displayName: "name2"
email: "email2@example.com"
contentType: application/json and tricky part: |
Ah, so we need to add |
examples there is an array with at least two possible keys "payload" & "header", spec said: |
@strobe should be fixed in next 0.18.x :) |
Tapir version: ***
0.17.1
Scala version: ***
2.12.12
Describe the bug
Currently, it's possible to specify custom example/s for WebSockets endpoints but that will be ignored during AsyncApi documentation generation.
For instance:
after AsyncApi generation via 'AsyncAPIInterpreter.toAsyncAPI' both examples will be ignored, seems a single example that appears in the result generated directly from WsResponse objects/classes.
What's required to do in order to implement that? Where implementation for this should be added?
The text was updated successfully, but these errors were encountered: