2

I am using swagger from creating API documentation and I am facing problem in correct format of YAML from JSON file.

my JSON file:

{
    "oject": {
      "OTime": "2017-10-12 06:31:02.793",
      "PTime": "2017-10-12 16:15:00.000",
      "sum": 3.55,
      "pNumber": 8,
      "tpNumber": 11,
      "tdNumber": 1.75
    },
    "itemsObjectArray": [
           {
                "ProId" : 500,
                "Name" : "Love",
                "CItems" : [],
                "Quantity" : 1,
                "UnPrice" : 11.0000,
                "Price" : 11.5000,
                "PriceInD" : {}
            }, "ProId" : 500,
                "Name" : "Love",
                "CItems" : [],
                "Quantity" : 1,
                "UnPrice" : 11.0000,
                "Price" : 11.5000,
                "PriceInD" : {}
        ]
}

I tried this YAML and up to an extend I had succeeded but unable to understand how to repeat the same object in the array. YAML file:

responses: 
        '200':
          description: NA
          schema:
              type: object
              properties:
                 orderObject:
                   type: object
                   properties:
                      OTime:
                         type: string
                      PTime:
                         type: string
                      sum:
                         type: integer
                      pNumber:
                         type: integer
                      tPointsNumber:
                         type: integer
                      tdNumber:
                         type: integer
                 itemsObjectArray:
                    type: array
                    items:
                         type: object
                         properties:
                              ProId:
                                 type: integer
                              Name:
                                 type: string
                              CItems:
                                 example: []
                              Quantity: 
                                 type: integer
                              UnPrice:
                                 type: integer
                              Price:  
                                 type: integer
                              PriceInD:
                                 type: object 

And this is what I am getting right now

{
    "oject": {
      "OTime": "2017-10-12 06:31:02.793",
      "PTime": "2017-10-12 16:15:00.000",
      "sum": 3.55,
      "pNumber": 8,
      "tpNumber": 11,
      "tdNumber": 1.75
    },
    "itemsObjectArray": [
           {
                "ProId" : 500,
                "Name" : "Love",
                "CItems" : [],
                "Quantity" : 1,
                "UnPrice" : 11.0000,
                "Price" : 11.5000,
                "PriceInD" : {}
            }
        ]
}

How to repeat the same objects within the array according to my YAML format in Swagger?

WhoAmI
  • 217
  • 1
  • 2
  • 23
  • @Helen I don't think so . Please see my JSON structure it is different. – WhoAmI Oct 12 '17 at 20:00
  • Sorry, wrong link. See [Return an array of object in Swaggerhub](https://stackoverflow.com/q/46167981/113116). – Helen Oct 12 '17 at 20:20
  • @Helen I did followed that , but unable to solve . I don't have any definitions in my code. I am new in this . Can you help me through my code? – WhoAmI Oct 13 '17 at 07:56

0 Answers0