maxdome / swagger-combine

Combines multiple Swagger schemas into one dereferenced schema.
MIT License
132 stars 36 forks source link

Add tags #2

Closed vincentvanderweele closed 7 years ago

vincentvanderweele commented 7 years ago

As described in #1, I added support for adding tags to all endpoints of a specific service, like this:

{
  "swagger": "2.0",
  "info": {
    "title": "Swagger Combine Rename Example",
    "version": "1.0.0"
  },
  "apis": [
    {
      "url": "http://petstore.swagger.io/v2/swagger.json"
    },
    {
      "url": "https://api.apis.guru/v2/specs/medium.com/1.0.0/swagger.yaml",
      "tags": {
        "add": [
          "Medium"
        ]
      }
    }
  ]
}

There are of course two places where tags are used: in the schema root and in every operation. I chose to only add these tags to the operation tags because the root tags will all be merged into a single array anyway (so it doesn't make much sense to allow adding tags per service).

I don't handle the case that an added tag already exists because renameTags doesn't handle that either. I also chose to not add a new integration test for this functionality but this can of course be added if needed.

fabsrc commented 7 years ago

Hi Vincent,

thank you for your contribution :blush: This feature really is a great addition to this module. However there are two things you could improve in your PR:

Integration tests are optional, maybe we will add some later.

vincentvanderweele commented 7 years ago

Will do!

Currently I have a problem that an array gets converted to an object with integer keys. I'm not sure if my change is causing this, but if it is, I'll obviously fix that as well in this PR.

vincentvanderweele commented 7 years ago