specification icon indicating copy to clipboard operation
specification copied to clipboard

Redocly Decorator: x-feature

Open 0xkubectl opened this issue 1 year ago • 2 comments

POC for https://github.com/vrchatapi/specification/issues/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

0xkubectl avatar Jul 27 '24 20:07 0xkubectl

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?

ariesclark avatar Jul 28 '24 23:07 ariesclark

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.

0xkubectl avatar Jul 29 '24 15:07 0xkubectl