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 customising the RefStrategy used by JsonSchemaConverter/OpenApiConverter #2144

Open
Xtansia opened this issue Feb 15, 2024 · 2 comments
Labels
feature-request A feature should be added or improved.

Comments

@Xtansia
Copy link
Contributor

Xtansia commented Feb 15, 2024

While working on the Smithy specifications for OpenSearch we've come across a need to tweak how and when $refs are introduced into the OpenAPI schema we generate from Smithy. This directly maps onto modifying the RefStrategy used by JsonSchemaConverter so that we can customise when certain types are inlined versus not and also how the schema/ref is named.

Currently the RefStrategy is hard-coded to RefStrategy::createDefaultStrategy, so I propose allowing this to be configured in some manner to use a custom implementation.

@JordonPhillips JordonPhillips added the feature-request A feature should be added or improved. label Feb 20, 2024
@mtdowling
Copy link
Member

Can you describe what kinds of customizations you'd need from the RefStrategy? Assuming the changes aren't super niche, ideally we can add more high-level options to the plugin rather than directly allow customizing how refs are created. That'll help keep the converter maintainable while also making it easier for people to customize its behavior if necessary.

@Xtansia
Copy link
Contributor Author

Xtansia commented Feb 21, 2024

Our first use case is stopping specific schemas from being inlined that are currently always inlined (i.e. primitives & collections). This one I can see being implemented as a true feature using a marker trait that allows opting in or out of inlining, as it then becomes "free" to allow non-inlined types to be inlined (i.e. structures): @smithy.openapi#inline("never" | "always").

The second use case is to essentially insert a subsection of the namespace into the $ref path, e.g. OpenSearch.nodes._common#NodeResponseBase would become #/components/schemas/nodes._common:NodeResponseBase. This is the ask that I felt was far too niche to turn into a general feature, hence my framing this as allowing replacing the implementation of RefStrategy. This could also be done via trait or something, but annotating every single schema would be onerous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

3 participants