asyncapi-react icon indicating copy to clipboard operation
asyncapi-react copied to clipboard

No generated examples when using multi format schema object

Open Gyllsdorff opened this issue 10 months ago • 2 comments

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

Gyllsdorff avatar Feb 15 '25 10:02 Gyllsdorff

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 Feb 15 '25 10:02 github-actions[bot]

Hey @Gyllsdorff, kindly go ahead and open a PR 👍🏾

AceTheCreator avatar Mar 06 '25 11:03 AceTheCreator

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 Jul 05 '25 00:07 github-actions[bot]