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

Fixes #1004: Support Swagger tags #1211

Merged
merged 2 commits into from
Oct 17, 2018
Merged

Conversation

thewheat
Copy link
Contributor

Closes #1004

  • Adds support for Swagger tags which groups requests into folders

image

  • Also provides support for multiple tags in a single request: it will create duplicate requests to list them in multiple folders
    • A request with multiple Swagger Tags (i.e. Insomnia folders) is possible and displaying multiple times is expected as seen in this Swagger UI issue
    • Sample below is a modified json file where
      • Update an existing pet has tags of pet and store and
      • Add a new pet to the store has no tags

image

if (!tags || tags.length == 0) tags = [''];
tags.forEach((tag, index) => {
let id =
endpointSchema.operationId + (index > 0 ? index : '') || `__REQUEST_${requestCount++}__`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a suffix with index as if the request has multiple tags, each request needs a unique id and thus append index to make it unique

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that sounds like a good solution 👍

Copy link
Contributor

@gschier gschier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome! This has been requested for a long time so thank you for taking care of it 🎆

if (!tags || tags.length == 0) tags = [''];
tags.forEach((tag, index) => {
let id =
endpointSchema.operationId + (index > 0 ? index : '') || `__REQUEST_${requestCount++}__`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that sounds like a good solution 👍

@gschier gschier merged commit ebd3761 into Kong:develop Oct 17, 2018
luizmariz pushed a commit to luizmariz/insomnia that referenced this pull request Jan 22, 2020
@mawiseman
Copy link

What happened to this pr? seems to have never made it in?

@thewheat
Copy link
Contributor Author

Hi @mawiseman 👋 I've imported https://petstore.swagger.io/v2/swagger.json and correctly puts the requests in different folders (each folder represents the tag on the request) so it looks like it has been merged.

Do you have a URL / file where it doesn't work? That could help us figure out what's wrong 👍

image

These are my Insomnia details if it helps as well 😃

Version: Insomnia Core 2020.4.1
Release date: 9/23/2020
OS: Darwin x64 19.6.0
Electron: 9.1.1
Node: 12.14.1
V8: 8.3.110.13-electron.0
Architecture: x64
node-libcurl: libcurl/7.69.1 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.41.0

@mawiseman
Copy link

mawiseman commented Oct 13, 2020

Thanks for looking into this @thewheat

I have attached a cut down version of the swagger file I am trying to import.
swagger.json.txt

It was generated using the Swashbuckle library for dotnet core: https://github.com/domaindrivendev/Swashbuckle.AspNetCore

You can see it is valid when pasting it into the online editor: https://editor.swagger.io/

Insomnia Import & Swagger View

image

image

Here are my Insomnia details

Version: Insomnia Core 2020.4.1
Release date: 9/23/2020
OS: Windows_NT x64 10.0.18363
Electron: 9.1.1
Node: 12.14.1
V8: 8.3.110.13-electron.0
Architecture: x64
node-libcurl: libcurl/7.69.1-DEV OpenSSL/1.1.1d zlib/1.2.11 WinIDN libssh2/1.9.0_DEV nghttp2/1.40.0

@thewheat
Copy link
Contributor Author

Ah @mawiseman I see that your file says it is an OpenAPI specification and not a Swagger one (Insomnia currently has a different import for each of those and the one I modified was Swagger 😅
image

Swagger definition in the Petstore example
image

Did a test and if you add tags in the root definition it does correctly create the folders
image

Digging further, from #2408 it looks like the beahviour of needing to add it to global scope is expected. Not ideal but if anything, I think that issue would be best for any further discussion 👍

@mawiseman
Copy link

Thanks @thewheat!

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

Successfully merging this pull request may close these issues.

[Feature Request] Add group endpoints by tags for swagger
3 participants