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

Redocly Decorator: x-feature #371

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

0xkubectl
Copy link

POC for #370

This is a draft and not done. Its more to see if the idea works and to gague how other contributers like the impl.

Things missing:

  • adapt workflow
  • figure out where to save different versions of the spec
  • tests

Not sure if there is the right place to put this plugin. Feedback is welcome :3

@ariesclark
Copy link
Member

ariesclark commented Jul 28, 2024

Is there any particular reason behind changing the structure of the proposal? And I'm not sure where available_features comes from. Is this code functional?

@0xkubectl
Copy link
Author

The code is functional, if you have a look here, you can see that available_features is a configuration value. The idea being that this decorator can deal with more that one feature at a time. I.e. there are 3 Features of OpenAPI requried to accurately describe an Api. As some generators only support a different subset of those features, you can run redocly with different config values and produce specs that satisfy the feature constraints of a given generator.

If I understood you proposal correctly the decorator would only have supported one feature (either use the fallback or dont), which would limit the use of other operators like anyOf or allOf. On why I changed the exact syntax, I wanted it to be clear what is replaced and how. If all required features are present x-feature will be rendered what is in the desired object and otherwise whats in the fallback object. Futhermore I believe this allows for more flexibility as instead of just one key, a whole object with multiple properties can be added or removed, based on features.

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

Successfully merging this pull request may close these issues.

2 participants