Ask a Question

Data model definition?

jnazander
New Member

Data model definition?

Why doesn't Swagger Inspector generate the date model definition for API responses? Is it a bug or just not implemented?

 

Correct definition:

 

                "responses": {
                    "200": {
                        "description": "successful operation",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Pet"
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid status value"
                    }
                },

Swagger Inspector generated code:

 

      responses:
        default:
          description: Definition generated from Swagger Inspector
13 REPLIES 13
ShannonWallace
SmartBear Alumni (Retired)

Hi there,

 

Thank you for calling our attention to that, and sorry for the late reply. That feature is just not implemented yet. If anyone else wants this feature, please comment on this thread! We do have this in the backlog of to-do's, but have a number of features above it, such as supporting Safari and Firefox.

 

Thanks for the feedback!

Shannon Wallace
Product Manager
SmartBear Software
mrg
Occasional Visitor

Without to generate the data model definition for API responses this tool is useless. This should have top priority.

ShannonWallace
SmartBear Alumni (Retired)

Hi there,

 

Thank you for the feedback. This is, in fact, our top priority. We just started work on OAS 3 support, and making sure to include responses (and more) is part of what we'll do.

 

Shannon Wallace
Product Manager
SmartBear Software

Hi Shannon,

I am also looking for this feature as mentioned during our phone call couple of days back.

 

/Vineeth

ShannonWallace
SmartBear Alumni (Retired)

Hi Vineeth (et al),

 

This was at the top of our list, and we added response information to newly created OAS 3 API definitions. I just created a definition, and I see this in the definition for a response of a request I made with Swagger Inspector. Is this not what you're looking for?

 

  /api/planets:
    get:
      description: Auto generated using Swagger Inspector
      responses:
        '200':
          description: Auto generated using Swagger Inspector
          content:
            application/json:
              schema:
                properties:
                  films:
                    type: array
                    properties:
                      items:
                        type: string
                  edited:
                    type: string
                  created:
                    type: string
                  climate:
                    type: string
                  rotation_period:
                    type: string
                  url:
                    type: string
                  population:
                    type: string
                  orbital_period:
                    type: string
                  surface_water:
                    type: string
                  diameter:
                    type: string
                  gravity:
                    type: string
                  name:
                    type: string
                  residents:
                    type: array
                    properties:
                      items:
                        type: string
                  terrain:
                    type: string

 

If that's not what you're looking for, could you clarify? The 'description' parts needs input from someone who can describe what the endpoint does, of course, because we don't really know that from our side (although I guess we could put in something like 'Creates a new XX' for POST methods, where XX is the end of the URI path).

 

Thanks in advance!

Shannon Wallace
Product Manager
SmartBear Software

Hi Shannon,

       Yes this is what I am looking for. But I don't see it when I tried to generate OAS 3.0 API definition out of my API response. So, I am not able to generate data model definition in both OAS 2.0 and  3.0 using https://inspector.swagger.io/builder

 

sample definition generated:

openapi: 3.0.1
info:
----------

----------

-----------
responses:
default:
description: Auto generated using Swagger Inspector

 

/Vineeth 

ShannonWallace
SmartBear Alumni (Retired)

Hi Vineeth,

 

Hmm, I can't reproduce not getting the response information. I've asked Kevin (who you've been in touch with here) to pass me your information so that I can get more details from you to see if I can reproduce what you're seeing.

 

Thanks!

Shannon Wallace
Product Manager
SmartBear Software

I'm having the same problem, but I was able to get a swagger file with the model definitions but not anymore.

 

Yesterday was the first time I used Inspector. I created a sample API using FB Graph API. Ran a couple of tests and then used the "Create API" button to export to Editor. Everything worked fine and I saw all the models. 

 

Today, I've expanded the definitions in Inspector, but I can't figure out anyway to get the models. I only see 

 

responses:
        '200':
          description: Definition generated from Swagger Inspector

at the end of the file. I've tried OAS2.0 and 3.0. I've tried logging out and back in. Deleting my history and starting over. Nothing I do gets my models created again.

Doing a little trial and error and finding that very simple responses are described in the output. With a single level json response, I see that model in the editor. I'll try and figure out what type of response is breaking it.

 

Looks like the Inspector must fall apart on more complex responses and just truncate output.

cancel
Showing results for 
Search instead for 
Did you mean: