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

Can't show second level subtypes of response class #703

Closed
luuvthanh87 opened this issue Oct 31, 2014 · 3 comments
Closed

Can't show second level subtypes of response class #703

luuvthanh87 opened this issue Oct 31, 2014 · 3 comments

Comments

@luuvthanh87
Copy link

Hi all,
This is my model

BaseModel{
  string name;
}

FirstSubType extends BaseModel{
   string firstValue;
}

SecondSubType  extends BaseModel{
   string secondValue;
}

My rest api return BaseModel, for mpoindexter/swagger-js@68ea66f swagger UI can show model of FirstSubType, but I only want swagger UI show model of SecondSubType

Can I do that?

Thanks in advanced.
Thanh

@webron
Copy link
Contributor

webron commented Oct 31, 2014

Need some more info. Is this Swagger 1.2 or 2.0? Do you have an existing swagger json? If so, can you share it?

@luuvthanh87
Copy link
Author

Hi @webron, the swagger version is 1.2 and this is my model

{
    "Product": {
      "type": "object",
      "id": "Product",
      "required": [
        "Id",
        "Name",
        "CategoryId"
      ],
      "properties": {
        "Id": {
          "type": "integer",
          "format": "int32"
        },
        "Name": {
          "type": "string"
        },
        "CategoryId": {
          "type": "integer",
          "format": "int32"
        },
        "ImageUrl": {
          "type": "string"
        },
        "Type": {
          "type": "string"
        }
      },
      "subTypes": [
        "Shoe"
      ],
      "discriminator": "Type"
    },
    "Shoe": {
      "type": "object",
      "id": "Shoe",
      "required": [
        "Size"
      ],
      "properties": {
        "Size": {
          "type": "integer",
          "format": "int32"
        }
      },
      "subTypes": [
        "Nike"
      ]
    },
    "Nike": {
      "type": "object",
      "id": "Nike",
      "required": [
        "NikeId"
      ],
      "properties": {
        "NikeId": {
          "type": "string"
        }
      },
      "subTypes": []
    }
  }

Product is top class, Shoe inherits Product, and Nike inherits Shoe.

@fehguy
Copy link
Contributor

fehguy commented Dec 29, 2014

Hi, this will be supported, but for 2.0 specs. Please track here:

swagger-api/swagger-js#188

@fehguy fehguy closed this as completed Dec 29, 2014
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

No branches or pull requests

3 participants