Create default value for array item in sample request body using smartdocs

Not applicable

Hi, how do you create a sample post request body that includes default values for arrays? For example,

`{"gender": "female", "married": true, "areaCode": "312", "totalContactsPerYear": [0, 0, 1, 0, 1, 0]}`

We can successfully supply default values through smartdocs for strings and booleans, as seen below

`properties:

gender:

type: string

default: "female"`

However, whenever we try to put a default value for the array, it just shows up as `[0]` . We've tried the approach below. We also tried passing in an actual array for the defaultValue, but it didn't work, either. Any help would be appreciated, thanks!

`totalContactsPerYear:

type: array

items:

type: integer

defaultValue: 0, 0, 1, 0, 1, 0`

1 4 229
4 REPLIES 4

@emcfc , Welcome to Apigee Community !

Can you please attach sample spec file if possible.

As requested - Definitions used and expected sample request are attached.

All default values appear as expected, except for type array. Resolution is appreciated

objectdefinitions.pdf

samplerequest.pdf

Hi @Anil Sagar, since viewing our spec file, can you (or any other Apigee community members) see any way for us to resolve this issue? Thanks for the help!

rpet2
New Member

@Anil Sagar: Is there an answer for this? What is the correct syntax for defining default values for arrays like in the objectdefinitions.pdf above?