-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Example override for ref schema object not working #495
Comments
@christianrowlands the problem you are experiencing here is because the standard dictates it. When you define schemas with no custom schemaFormat, it's gonna be AsyncAPI Schema Object, which is superset of JSON Schema draft 7. Which states: https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.8.3
Take notice of I don't think there is a concept of inheritance in JSON Schema, the best they can do is use a combination of There might be another schemaFormat you can use that support this better 🤔 |
Thank you for the information. I looked through the other schemaFormats and I don't think they will fit my full use case. The strange part is that the override I am describing has worked as expected since ~2020 until the beginning of 2023, and then all of a sudden broke. I am guessing that I was benefiting from some semantic behavior that was a "bug", and it was fixed recently. This is a shame because it allowed for the DRY principle when creating your AsyncAPI files. I think I will just copy and paste a duplicate version of each item I want to "override". That seems like the safest option at this point. I appreciate all the help with this. |
seems to be completed discussion @christianrowlands feel free to open a separate issue if you have further questions |
Note: Issue #463 had two bugs mentioned in it, so I am creating this ticket to pull one of the bugs out so it can be tracked individually (my bad for lumping them together).
Describe the bug
The example that I set for a field is not being used in the generated HTML when using a $ref to a schema.
I have published my AsyncAPI HTML docs on public URL, so you can see both issues on that site.
if you look at any of the Payload schemas, they all have a messageType field. A couple months ago I noticed that the override description and example stopped working. For example, with the GSM Record under the gsm_message operation, the messageType should be The type of message, must be GsmRecord. since that is what I set it to here in the yaml spec.
In addition, the example is also not being overridden as expected. I set it to GsmRecord here in the yaml spec but in the generated doc it shows up as string. Below is a screenshot of the linked generated HTML:
How to Reproduce
For reproducing the issue, you can either use the full yaml spec I have linked to that is in my GitHub repo, or you can use this condensed version I made below. I typically use the docker container for asyncapi to generate the yaml. Something like:
docker run --rm -it -v ${PWD}/asyncapi/test.yaml:/app/test.yaml -v ${PWD}/testdoc:/app/output asyncapi/generator:1.17.0 /app/test.yaml @asyncapi/[email protected] -o /app/output --force-write
Expected behavior
The expected behavior is
GsmRecord
.The type of message, must be GsmRecord.
The text was updated successfully, but these errors were encountered: