How to specify empty string value as default in open api specification for an attribute of type string

Viewed 5423

I have a open api yaml file like below. I want to assign empty string value as default to string type property. What is the way to do this

  Test:
type: object
required: ['', '']
properties:
  test1:
    type: string
    default: " "
2 Answers

Pretty sure it's:

default: ""

That is, without the whitespace in it.

Swagger string type show "string" if default is "".

default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if type is string, then default can be "foo" but cannot be 1.

Here is issue topic: https://github.com/swagger-api/swagger-codegen/issues/43

Related