I can't seem to get the model to structure the output properly..

19 views
Skip to first unread message

xhorntail

unread,
Oct 5, 2017, 6:03:07 PM10/5/17
to Swagger
Brand new to this, so I'm not certain on all the terminology and such. I'll just post my code and output here, and then explain what I'm expecting to get instead.

Editor code:
  /user_agents:
    get:
      tags:
        - user_agents
      summary: List
      parameters:
        ..removed for readability..
      responses:
        '200':
          description: An array of user_agents
          schema:
            type: array
            items:
              type: object
              properties:
                user_agent_id:
                  type: integer
                  x-dbtype: int
                  x-nullable: false
                  x-primary-key: true
                user_agent_string:
                  type: string
                  x-dbtype: varchar
                  x-nullable: true
                  maxLength: 255

Server Response:
{
  "user_agents": [
    {
      "user_agent_id": 1,
      "user_agent_string": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36",
      "user_agent_use_count": 1
    },
    {
      "user_agent_id": 2,
      "user_agent_string": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36",
      "user_agent_use_count": 1
    },
    {
      "user_agent_id": 3,
      "user_agent_string": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36",
      "user_agent_use_count": 2
    }
  ]
}


Structured output:
[
  {
    "user_agent_id": 0,
    "user_agent_string": "string"
  }
]


For some reason, neither the editor panel or the generated client are able to process this correctly.. I can't get them to output the actual values of the returned object.
Any and all help is appreciated!

Ron Ratovsky

unread,
Oct 5, 2017, 6:22:02 PM10/5/17
to swagger-sw...@googlegroups.com

You’re only describing the inner array. You need to describe the encompassing object, the one containing the “user_agents” property.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xhorntail

unread,
Oct 5, 2017, 6:25:33 PM10/5/17
to Swagger
Sorry, I'm super new to this. Any chance you could demonstrate what you mean? I've inherited this project, and it's a bit out of my comfort zone.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Oct 5, 2017, 6:37:14 PM10/5/17
to swagger-sw...@googlegroups.com

Replace your schema with:

          schema:

            type: object

            properties:

              user_agents:

                type: array

                items:

                  type: object

                  properties:

                    user_agent_id:

                      type: integer

                      x-dbtype: int

                      x-nullable: false

                      x-primary-key: true

                    user_agent_string:

                      type: string

                      x-dbtype: varchar

                      x-nullable: true

                      maxLength: 255

 

 

 

xhorntail

unread,
Oct 5, 2017, 7:00:29 PM10/5/17
to Swagger
Seems like it should be working, perhaps I'm daft, but the model still isn't populating.

server response:
{
  "user_agents": [
    {
      "user_agent_id": 1,
      "string": "asdasdad"
    }
  ]
}


Responses:
{
  "user_agents": [
    {
      "user_agent_id": 0,
      "user_agent_string": "string"
    }
  ]
}



Ron Ratovsky

unread,
Oct 5, 2017, 7:40:12 PM10/5/17
to swagger-sw...@googlegroups.com

The UI generates a sample response, it doesn’t show you the actual response unless you execute the call.

 

 

 

From: <swagger-sw...@googlegroups.com> on behalf of xhorntail <xhor...@gmail.com>
Reply-To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Date: Thursday, October 5, 2017 at 16:00
To: Swagger <swagger-sw...@googlegroups.com>
Subject: Re: I can't seem to get the model to structure the output properly..

 

Seems like it should be working, perhaps I'm daft, but the model still isn't populating.

server response:

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Landon Snell

unread,
Oct 5, 2017, 7:43:05 PM10/5/17
to swagger-sw...@googlegroups.com
I have clicked the button if that's what you mean

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/jGJLLUJ9czA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Oct 5, 2017, 7:56:39 PM10/5/17
to swagger-sw...@googlegroups.com

Then I don’t understand the issue.

 

 

 

From: <swagger-sw...@googlegroups.com> on behalf of Landon Snell <xhor...@gmail.com>
Reply-To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Date: Thursday, October 5, 2017 at 16:43
To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Subject: Re: I can't seem to get the model to structure the output properly..

 

I have clicked the button if that's what you mean

 

On Oct 5, 2017 5:40 PM, "Ron Ratovsky" <r...@swagger.io> wrote:

The UI generates a sample response, it doesn’t show you the actual response unless you execute the call.

 

 

 

From: <swagger-sw...@googlegroups.com> on behalf of xhorntail <xhor...@gmail.com>
Reply-To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Date: Thursday, October 5, 2017 at 16:00
To: Swagger <swagger-sw...@googlegroups.com>
Subject: Re: I can't seem to get the model to structure the output properly..

 

Seems like it should be working, perhaps I'm daft, but the model still isn't populating.

server response:

{

  "user_agents": [

    {

      "user_agent_id": 1,

      "string": "asdasdad"

    }

  ]

}



Responses:

{

  "user_agents": [

    {

      "user_agent_id": 0,

      "user_agent_string": "string"

    }

  ]

}

 

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/jGJLLUJ9czA/unsubscribe.

To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages