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

No generated examples when using multi format schema object #1125

Open
Gyllsdorff opened this issue Feb 15, 2025 · 1 comment
Open

No generated examples when using multi format schema object #1125

Gyllsdorff opened this issue Feb 15, 2025 · 1 comment

Comments

@Gyllsdorff
Copy link

Description

https://www.asyncapi.com/docs/reference/specification/v3.0.0#messageObject

payload
Multi Format Schema Object | Schema Object | Reference Object
Definition of the message payload. If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.

The AsyncAPI spec says we can provide the schemas in 3 ways:

  1. A inline schema
  2. A reference to a schema
  3. A object with the keys schemaFormat and schema where schema will be either a inline schema or a reference to a schema

If you use option 3 then MessageHelpers.generateExample will call the sample generator with the {"schemaFormat": ..., "schema": ...} root object instead of the actual schema that is found under schema.schema. 😅

Image

It is possible to work around this in some cases by providing the schema using option 1 or 2 if you only use a syntax that is compatible with application/vnd.aai.asyncapi+json but that don't support AVRO based schemas for example.

Fix:
Check in https://github.com/asyncapi/asyncapi-react/blob/master/library/src/helpers/message.ts#L9 if the object matches the shape of a "multi format schema object" and call the ´schema.schema` in that case.

I can provide a PR if that fix is acceptable.

Expected result
A basic example

Actual result
A empty example

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant