mtennoe / swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.
Apache License 2.0
140 stars 52 forks source link

add support for `response refs` #84

Closed Kosta-Github closed 5 years ago

Kosta-Github commented 5 years ago

The swagger spec allows to define an optional root level responses object which allows to reuse response definitions for several endpoints; see: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#fixed-fields

This PR adds support for this potential additional level of indirection.

Check the added endpoint def for /Admin/{id} in tests/apis/test.json. It contains this reference to a shared response definition:

    "responses": {
        "200": {
            "$ref": "#/responses/get_admin_200"
        }
    }

which is pointing to this response definition on the root level:

    "responses": {
        "get_admin_200": {
            "description": "Admin user details",
            "schema": {
                "$ref": "#/definitions/User"
            }
        }
    }
mtennoe commented 5 years ago

@Kosta-Github - Seems you you closed this - intentional?

Kosta-Github commented 5 years ago

yes, the PR didn't fix all potential combinations I am seeing in the variant swagger specs I am dealing... I will try to come up with a new proposal...

mtennoe commented 5 years ago

Sounds good!

Kosta-Github commented 5 years ago

this is the follow-up PR: https://github.com/mtennoe/swagger-typescript-codegen/pull/87