cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

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

"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. ⬇️⬇️⬇️

View solution in original post

3 REPLIES 3
Highlighted
Moderator

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

"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. ⬇️⬇️⬇️

View solution in original post

Highlighted
New Contributor

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

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

Highlighted
New Contributor

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

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.

New Here?
Join us and watch the welcome video: