3

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: " "
user3128995
  • 61
  • 1
  • 5
  • On an unrelated note: `required: ['', '']` is most likely not a valid syntax. The `required` list is supposed to contain actual property names of that object, such as `required: [test1]`, – Helen Jul 01 '19 at 08:40

2 Answers2

0

Pretty sure it's:

default: ""

That is, without the whitespace in it.

von_court
  • 152
  • 2
  • 10
  • Its not working with default: "" for string data type. – user3128995 Jul 01 '19 at 05:39
  • @user3128995 Can you clarify what you mean by "not working"? Where exactly does it not work? What result do you expect and what is the actual result? – Helen Jul 01 '19 at 08:38
0

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

Chris
  • 6,914
  • 5
  • 54
  • 80
Song
  • 593
  • 9
  • 21