OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

Allow anyOf in specification

Open paulhill opened this issue 11 years ago • 5 comments

We don't necessarily need to support anyOf for tooling. I know the code generation authors like the definition of type hierarchy that comes with allOf inheritance. But it would be so nice to be able to specify an anyOf array. Even if swagger spec validation just ignored it that would be an improvement. It seems so restrictive to disallow certain types of schema validation just because tool authors aren't supporting it.

:-/

paulhill avatar May 25 '15 23:05 paulhill

A big part of what I liked about swagger 1 was that I could re-used my json-schema validation as my model definitions. That went away with swagger 2.0

paulhill avatar May 25 '15 23:05 paulhill

Actually, we necessarily need to support it.

While strictly speaking, Swagger is the specification, the specification itself means nothing without proper tooling support.

While you may not be looking it, once we put it in, users would start asking for it (and rightfully so). This is true for other features that are not yet fully implemented in the tools (though are easier to implement).

We're trying to think of ways to add support for anyOf in the future though.

webron avatar May 26 '15 14:05 webron

Just as a use-case here. We use a Swagger file to define our API so that we get pretty documentation, etc.. This works great. We have the need to use an anyOf - so right now we we provide a "dummied up" schema that is "pretty close" but not correct. Then we document that in the Swagger doc parts. At runtime, we point to a different place inside the Swagger.json file that is using anyOf (because our any of is making references we keep all of the JSON Schema in the same file). Anyway while I realize it will be a long time if ever a code-generation tool could support that, we do our server in JS (and clients too). So just throwing it out there that we use Swagger, and anyOf support would be great, as we have a slightly awkward work-around.

coding2012 avatar Feb 08 '16 15:02 coding2012

Tackling PR: #741

webron avatar Jul 21 '16 21:07 webron

This has been merged.

fehguy avatar Feb 01 '17 20:02 fehguy