-
Notifications
You must be signed in to change notification settings - Fork 9.1k
OpenAPI.next: Allow recursive paths #647
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
Comments
I think this abuses the path key too much. Better to keep at top-level, or at path item level. |
@fehguy Can you please elaborate. |
yes to all. It's an overload of a path name (is |
It's easy, only keys what starts with
I agree with this one. It requires tool author to write additional 50-100 SLOC. |
It's not an argument, just thing to note. But I don't say OpenAPI should automatically borrow from other formats, especially from WADL. |
@IvanGoncharov I think it is a fairly fundamental difference in the way APIs are described. Admittedly paths are naturally hierarchical, and getting the reuse ability for free is nice. However, it doesn't help when it comes to re-use of query parameter descriptions. Personally I find deep paths are often a design smell in APIs and I'm not sure we should be encouraging them. If other design formats support that style of API description and you find that more natural, then take advantage of it. I'm not sure the goal should be to make all API description languages work the same way. |
This can lead to some nasty structures too - potentially describing the entire API as one big deeply nested tree. Putting aside the issues it may cause tools, it would be harder for human-readability as well. This also potentially puts us back to 1.2 and earlier versions with the organization concept of resources. One of the goals of moving to tags for grouping was to allow the flexibility there. I don't find the benefits enough, especially with the supported reusability. |
Totally agree, it's part of the evolutionary process.
I see that hierarchical structures in JSON/YAMl are a question of personal taste.
But I don't want to turn this into some kind of bike-shed discussion. My proposal is to leave this issue open for few weeks to maybe have some feedback from the community. |
From a human factors perspective, nesting is normally the preferred structure. Originally, that was what I preferred about RAML over Swagger. But with OAI, the content is verbose enough that nesting does not help - there is too much info to fit nicely into a single screen unless the tools to a really good job with collapsing sections. Constantly expanding/collapsing gets pretty tedious. I agree reusing parameters is useful and a desired feature. One must be careful with adopting nesting because you to clarify exactly what is inherited from the parent. All parameters with (We actually have an internal tool that we're integrating into our Swagger editor which can add a missing path parameter by finding a matching Looking outside API descriptions, I think this is somewhat analogous to object modeling in OO languages. Inheritance was cool, but then it got abused, and composition became a preferred way to model things. Languages which only support single inheritance are less powerful/expressive than those that allow composition/mixins/traits. Nesting paths feels analogous to OO inheritance. See also OAI/Overlay-Specification#34 for an alternative to nesting -- use parameter sets. |
I too think this should be part of the spec. Surprised its not. |
This looks to me like a very useful feature, and i'm not sure why it was closed. Is it abandoned ? Anyway, allow me to expose a legitimate usecase that only this nesting feature would fulfill (as fas as I understand): service composition. I'd happy to know if there's another way to implement it. Let's say we have two independent services, A and B, each coming with their respective service descriptions
Then there's a need to deploy a service C, that composes A and B under two subpaths :
Can you comment on this usecase ? |
@pduchesne I'm pretty sure your use case is different from the original use case in the issue. The issue was about being able to nest path descriptions under each other to arbitrary depths to factor out common path prefixes. You are just combining paths from two sources, but at the same level (your end result is equivalent to manually copying everything from A's |
yes, I understand that the original issue is about potentially arbitrary deep nesting, while my example is about factoring out the first level of the path. |
@pduchesne if you have a new question different from the one raised in this issue, you should open a new issue. |
In OpenAPI 2.0 paths like
/user/{userId}/
and/user/{userId}/history
considered as totally separate paths with nothing in common even path parameters. Moreover, you can't define global parameters.I propose to allow for recursive paths, it would look like that:
Pros:
/user/{userId}/
and/user/{userId}/history
as separate paths.#/parameters/<name>
.description
into pathObject see added description field #632 (comment)consume
,produce
,responses
will be added into pathObject, remove a lot of duplication.patternProperties
.Cons:
The text was updated successfully, but these errors were encountered: