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

Feature: sub-tags grouping

Open kamil-kielczewski opened this issue 6 years ago • 66 comments

I don't know it is good place to introduce new Feature into swagger specification - if not please give me information where i can put this proposition.

My proposition is to use following convention in tags names (using dots to nesting subtags):

users.client     # and use this tag to client GET/POST/...
users.seller     # and use this tag to seller GET/POST/...
users.admin      # and use this tag to admin GET/POST/...
books            # use this to general books GET/POST...
books.sell       # use this to GET/POST... associated with the sell
books.management # use this to GET/POST... associated with the books management

And in output generated documentation web-page we will get:

user >
       client >
GET
POST
...
       seller >
GET
POST
...
       admin >
GET
POST
...

books >
GET
POST
...
       sell >
GET
POST
...
       management >
GET
POST
...

This feature is especially practical for large APIs.

Or may be better way is not change 'tags' but rather add new filed 'groups' which will contain such dot-separated nested groups?

kamil-kielczewski avatar Oct 05 '17 06:10 kamil-kielczewski

Hi @kamil-kielczewski

Adding the path level tagging solves the requirement, if I understood correctly. I have raised a PR https://github.com/OAI/OpenAPI-Specification/pull/1509 for the same.

Thanks, Mohammed

ymohdriz avatar Mar 15 '18 07:03 ymohdriz

I support the request for a sub-tags. I want to be able to group (or at least sort) the methods under each of my endpoints, and as far as I can tell, that's not possible right now.

maaland avatar Jul 30 '18 13:07 maaland

I support the request for sub-tags. Right now my tags are my collections. But with some collections exposing several different resources that can each support GET, PUT, and PATCH, the tags can become very cluttered. I want to be able have sub-tags for each resource within the collection tag.

jukeblimp32 avatar Sep 18 '18 22:09 jukeblimp32

I support the request for sub-tags. I have a big API with tens of access points that need categories.

farmbotgianpaolo avatar Nov 29 '18 02:11 farmbotgianpaolo

This is one area where apib is better... there is a hierarchy like "Resource Group > Resource > Transition" where a Transition is roughly an OAS path and a Resource could be represented with an OAS tag.

For large APIs it would be useful to be able to group the endpoints at a level above single tags.

OAS is flexible enough I can represent this in the data with some combination of tags and extension properties, but for it to really be useful you would want a standardised representation that the tools such as Swagger UI then also support.

anentropic avatar Apr 08 '19 21:04 anentropic

I have a very large API to document, large with a very basic structure: API { Service 1 { Tool 1, Tool 2, Tool 3, (etc) } Service 2 (etc) { Tool 1, Tool 2, Tool 3, (etc) } ... } Being able to link one path to two tags and having them fall in a parent-child structure, would solve this problem. I have played around with the entire spec and it simply won't stretch to accommodate this API. Has this need been addressed yet? I find a great number of people needing this, but no answers on how to accomplish this yet - has anyone found a work-around on this limitation?

amandajordaan avatar Jun 03 '19 14:06 amandajordaan

We have an OpenAPI document that is 540K lines long https://github.com/microsoftgraph/msgraph-metadata/tree/master/openapi/beta We put dots in the tags and operations to create namespaces. I don't expect UI tools and code-generators to be able to handle specifications this size. I built a tool that splits OpenAPI documents based on tags and then feed the smaller docs to tools.

I don't think asking tooling to handle very large API descriptions is the right answer. Divide and conquer and split your API into smaller, more manageable chunks.

darrelmiller avatar Aug 09 '19 16:08 darrelmiller

Hi @darrelmiller, Thanks for your experience. I would like to know if you could share the tool which splits the tags in OpenAPI documents.

ymhuang0808 avatar Dec 18 '19 10:12 ymhuang0808

Yes @darrelmiller pls do share what tool you used to create tag hierarchy

storm367 avatar Jan 24 '20 09:01 storm367

The code for it is here https://github.com/darrelmiller/apislice/tree/master/apislice but I'm am working to move it into a command line tool that anyone will be able to use.

darrelmiller avatar Jan 24 '20 15:01 darrelmiller

we have similar problem with OpenAPI as of now. feels like using tags approach is more of a workaround rather than a proper solution. would it be possible to have an extra parameter in specification (which can be later picked up by projects like openapi-generator) where users can define the resource name where method belongs? IMO this would be a better solution, since for tags it is possible that

a. multiple "resource-like" tags could be used for one method, effectively making it ambiguous behaviour b. tags are more informational than definitive data, does not feel like resource path should be defined

shybovycha avatar Feb 09 '20 01:02 shybovycha

This issue is already more than 2 years old and my swagger UI page of current project is a big mess qua sorting, while the project is only small/medium sized. So doesn't look good. I saw some pretty low impact PR was being closed with argument "we need to know if existing workflows find this useful". In the same time there is a big PR with an unclear state to add many to many relationships and nested resources and that kind of stuff. But it looks big and complicated. So, wouldnt it be a great idea to have in the meantime a light weight iteration based on the tags? It would help my "existing workflow" for sure.

jantuitman avatar Feb 28 '20 09:02 jantuitman

I +1 this feature request, and put my vote behind the fully backward-compatible scheme in which tags remain a single string with the option of a special delimiter character to denote hierarchy (e.g., Main Tag|Sub Tag|Tertiary Tag). My preference is | or :, as these are common delimiter characters in other tagging schemes, but it looks like there's some momentum around ., and I would be happy with that as well.

It's fair to note that, given the above, this feature request is completely impertinent to OAS and is instead an implementation detail of docs viewers. Given that, it should be fairly simple for docs viewers to implement support for this post-hoc, so I'm personally going to go forward with using the scheme and encourage docs viewers to catch up.

kael-shipman avatar Apr 20 '20 20:04 kael-shipman

Tag names are hugely important when Swagger-Codegen creates client SDKs. For example, in a JavaScript client the tag names become class names. Any proposal for a feature that is mostly for doc viewers needs to also consider any implications for generated client SDKs.

SteveNay-vz avatar Jan 05 '21 19:01 SteveNay-vz

This is a very good point! It's certainly worth considering, although I would argue that the code generators may have taken some liberties in using what is technically a free-text string field for something so specific. This, of course, is the danger in including broad-purpose fields in a spec.

At any rate, it does seem like it would be worthwhile to include additional information about tags that could help both code generators and doc generators, and that information would probably be best captured in a Tag object.

Perhaps it could be as simple as adding an additional field, classname (or similar), in the Tab object specification that code generators can use to generate SDKs. Alternatively, code generators could either strip out non-alphanum characters or honor the hierarchy convention by dividing the SDK into subclasses according to the tag hierarchy.

I would think the latter would be the more appealing option, in which case this adds strength to the argument for hierarchicalizing tags.

kael-shipman avatar Jan 05 '21 20:01 kael-shipman

I haven't looked at them but surely the code generators must already be normalising and stripping invalid chars, and concatenating multiple tags, if they are using these as the basis of classnames in the clients... otherwise they're already broken, since it's already a free text field

anentropic avatar Jan 05 '21 21:01 anentropic

Yes, Codegen normalizes tag strings when creating client SDKs.

The issue that I was trying to raise is that OpenAPI definitions aren't used just to create API documentation; they are written in a machine-readable format so that code can be generated directly from the definition. Thus, any proposed changes need to work for these different purposes, or at least not get in the way.

SteveNay-vz avatar Jan 05 '21 22:01 SteveNay-vz

Waleed-131

wvieed avatar Jan 06 '21 07:01 wvieed

whats the current state of this issue? will this be supported in the future?

andre-dasilva avatar Apr 20 '22 11:04 andre-dasilva

Sub-tags would be especially useful for large API with larges paths and sub-paths. +1 For this feature request.

lonode avatar Jun 21 '22 08:06 lonode

I manage a lot of very large API's with a ton of endpoints. This feature would really benefit those projects greatly. Would love if it could get some attention :(

nathan-fiscaletti avatar Jul 21 '22 23:07 nathan-fiscaletti

If it's useful to you, I've published a swagger plugin for this. See discussion and link to the plugin here.

kael-shipman avatar Jul 22 '22 15:07 kael-shipman

Hi i see these forum is from 2017 and now sep2022... Did someone found a solution for these? is possible to do these in swaggerUI 3.0 ? Thanks

ReivenIV avatar Sep 30 '22 10:09 ReivenIV

Hi i see these forum is from 2017 and now sep2022... Did someone found a solution for these? is possible to do these in swaggerUI 3.0 ? Thanks

I have a workaround but it requires work: build some custom code to grep all the elements from the json file which belong to a specific tag, and write them back in a separate json file. So i have multiple swagger docs for our 1 project.

jantuitman avatar Sep 30 '22 10:09 jantuitman

@ReivenIV I've published a Swagger plugin for this here. See additional discussions here.

kael-shipman avatar Sep 30 '22 16:09 kael-shipman

Hey 2022 is also ending whats the current state of this issue? any solution ?

bhuvneshgalaxy avatar Dec 07 '22 05:12 bhuvneshgalaxy

I am also awating for the same. Someone please implement this feature.

amandeepnetweb avatar Dec 19 '22 09:12 amandeepnetweb

Hey, requesting team to please implement this feature.

mankrit-singh avatar Jan 04 '23 06:01 mankrit-singh

It's 2023 now... still no possibility to group tags .... as per this excelent proposal... what gives ?

dm-pr avatar Jan 09 '23 12:01 dm-pr

Hello from 2023 we need this feature but can't find any progress of this feature

sc-ahn avatar Jan 28 '23 12:01 sc-ahn