duncanhall/expand-swagger-refs

Ability to use stdin and stdout

Closed this issue · 6 comments

I'd really appreciate to see the ability to use stdin as input source and stdout as output source for the script, as that'd allow transformation of data, without writing it to (temporary) files in between.

Wow, I hadn't realised this was still in use. Is this still an issue now that swagger-api/swagger-ui#621 has been resolved/closed?

If so I'll have a look at accepting input from stdin.

I don't know about this particular issue, but it's quite handy when deploying an AWS API Gateway via a swagger template, as AWS has a limitation that they don't support references in response definitions (see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html for details).

Ah, I hadn't even considered AWS Gateway. I'm likely to run into that issue myself at some point so I'll try and get this done soon.

@Dunedan If you're able to provide a sample schema that requires expansion that would be a great help.

The following one should be a pretty minimal example, which requires expansion, before it works with AWS API Gateway:

{
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0.0",
    "title" : "Foo"
  },
  "paths" : {
    "/foo" : {
      "get" : {
        "parameters" : [ ],
        "responses" : {
          "200" : {
            "$ref" : "#/responses/bar"
          }
        },
        "x-amazon-apigateway-integration" : {
          "type" : "mock",
          "responses" : {
            "default" : {
              "statusCode" : 200
            }
          },
          "requestTemplates" : {
            "application/json" : "{\"statusCode\" : 200}\n"
          },
          "passthroughBehavior" : "when_no_match"
        }
      }
    }
  },
  "responses" : {
    "bar" : {
      "description" : "bar"
    }
  }
}

This util has been completely rewritten as an npm module and now supports stdin as well as direct function calls. See the homepage for more details and please raise any other issues/features separately.