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

Allow adding member docs to $ref #2402

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

milesziemer
Copy link
Contributor

Addresses #2400.

When a member targets a structure, it becomes a schema reference when converted to JSON Schema. Previously, we didn't add member docs to the converted object, possibly because earlier versions of open api or JSON Schema did not support it. Reading through this issue the OAI spec, and the JSON Schema Spec, it seems that OpenAPI 3.1 and JSON Schema 2020-12 support the description property alongside $ref. I wasn't able to find anything about whether it is supported in JSON Schema 07. This commit adds a new config option, addReferenceDescriptions that will add the description property alongside $ref when the member has documentation. I made it opt-in through the config option so we don't cause any existing documentation to be changed unexpectedly.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fixes smithy-lang#2400.

When a member targets a structure, it becomes a schema reference when
converted to JSON Schema. Previously, we didn't add member docs to the
converted object, possibly because earlier versions of open api or JSON
Schema did not support it. Reading through [this issue](OAI/OpenAPI-Specification#1514)
the [OAI spec](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object),
and the [JSON Schema Spec](https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3),
it seems that OpenAPI 3.1 and JSON Schema 2020-12 support the
`description` property alongside `$ref`. I wasn't able to find anything
about whether it is supported in [JSON Schema 07](https://json-schema.org/draft-07/json-schema-release-notes).
This commit adds a new config option, `addReferenceDescriptions` that
will add the `description` property alongside `$ref` when the member has
documentation. I made it opt-in through the config option so we don't
cause any existing documentation to be changed unexpectedly.
@milesziemer milesziemer requested a review from a team as a code owner September 23, 2024 16:34
@milesziemer milesziemer requested a review from yefrig September 23, 2024 16:34
Copy link
Contributor

@JordonPhillips JordonPhillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! We should add this to the examples repo here

@milesziemer milesziemer merged commit f630cbb into smithy-lang:main Oct 3, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

2 participants