thanks tony, it makes sense. i understand now, and by providing your answer you showed me another feature i did not know yet: example values great!, but in http://petstore.swagger.io/#!/pet/findPetsByTags I can see the example values with the example you provided (in the editor) I cant?
when i use http://petstore.swagger.io/v2/swagger.json in the editor, i can see the example values. it looks the examples are set like in your example [image: Inline image 1] but for my specs I now see the response structure, but not the example values...they do not show? is there something else that should be set to display the example values thanks again [image: Inline image 2] On Thu, Feb 23, 2017 at 7:22 PM, tony tam <[email protected]> wrote: > I suggest you try out the http://editor.swagger.io to experiment with the > specification. But here’s how it could be done: > > > # as a single inline object definition > definitions: > YourResponse: > type: object > properties: > Data: > type: object > properties: > Login: > type: array > items: > type: object > properties: > name: > type: string > example: Doe > firstname: > type: string > example: John > id: > type: integer > format: int64 > example: 461199 > password-expiry-utc: > type: integer > example: 20170223163054 > > # or in a flatter style using JSON references > definitions: > YourResponse: > type: object > properties: > Data: > $ref: '#/definitions/DataObject' > DataObject: > type: object > properties: > Login: > type: array > items: > $ref: '#/definitions/LoginRequest' > LoginRequest: > type: object > properties: > name: > type: string > example: Doe > firstname: > type: string > example: John > id: > type: integer > format: int64 > example: 461199 > password-expiry-utc: > type: integer > example: 20170223163054 > > > On Feb 23, 2017, at 8:46 AM, BG <[email protected]> wrote: > > Hi, > > I have this rather simple json response, in my swagger file I want to > write the definition that matches the response. > I got stuck - probably because because I am new to swagger. > > so at the end of the example below i want the definition for this json > response > > {"Data":{"Login":[{"name":"Doe","firstname":"John","id":461199, > "passhash-expiry-utc":"20170223163054"}]}} > > > below is how my swagger looks now. Can anyone get my back on track by > providing an example on how to write the definition? > > thanks! > > swagger: '2.0' > info: > version: ' 1.13.0003.00' > title: test (Simple) > description: An API > termsOfService: > contact: > name: Contoso > email: [email protected] > url: http://mydomain.com > license: > name: MIT > url: http://opensource.org/licenses/MIT > host: mydomain.com > basePath: /api > schemes: > - http > - https > consumes: > - application/json > produces: > - application/json > paths: > /login: > get: > description: > 'Returns basis user properties and passhash expiry date/time stamp > > as > > {"Data":{"Login":[{"name":"Doe","firstname":"John","id": > 461199,"passhash-expiry-utc":"20170223163054"}]}} > > ' > operationId: login > produces: > - application/json > parameters: > - name: pswauth > in: query > description: pswauthstring > required: true > type: string > responses: > '200': > description: login response > schema: > type: array > items: > $ref: '#/definitions/Login' > 'default': > description: unexpected error > schema: > $ref: '#/definitions/errorModel' > definitions: > errorModel: > type: object > required: > - code > - message > properties: > code: > type: integer > format: int32 > message: > type: string > Login: > type: object > required: > - code > - message > properties: > code: > type: integer > format: int32 > message: > type: 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 [email protected]. > 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/NZ5glQR6Quw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
