Ask a Question

How to create spec for Object with Sub-Objects with variable names? See example request body inside

SOLVED
poopsy
New Contributor

How to create spec for Object with Sub-Objects with variable names? See example request body inside

Hi there,

to clarify, here is the kind of Request Body I would like to spec out:

 

{
  "event" : "eventname",
  "payload" : {
    "Customer" : {
      "Mail" : "user@domain.invalid",
      "Firstname" : "Lorem ipsum",
      "Lastname" : "Lorem ipsum",
    },
    "Shop" : {
      "ShopUrl" : "Lorem ipsum",
    }
  }
}

 

The problem ist, the objects in the "payload" object should be variable - so not just necessarily "Customer" and "Shop", but variable object names and a variable number of objects.

 

I've tried to implement an API spec for this for the last 3 hours or so, but I'm getting nowhere. I'm wondering if this is even possible that way?

 

Any help would be greatly appreciated.

3 REPLIES 3
HKosova
SmartBear Alumni (Retired)

"payload" is a string-to-object dictionary. Dictionaries are defined as follows:

payload:
  type: object
  additionalProperties:
    type: object

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
poopsy
New Contributor

Ah, that seems to do exactly what I was looking for - thanks a lot! @HKosova 

Our server has swagger 2.0 specs. Will this work with it also? Meaning any concerns on client side SDK code generation? Thanks in advance.

cancel
Showing results for 
Search instead for 
Did you mean: