Empty default in schema is parsed as null
See original GitHub issueParser version:
2.0.2
Description:
OAS 3 spec (partial):
components:
parameters:
example:
name: example
description: example
in: query
required: false
schema:
type: array
items:
type: string
default: ''
The parameter schema parser treats empty strings as null.
schema.getDefault()
returns null
.
The following results in a proper default value being set:
components:
parameters:
example:
name: example
description: example
in: query
required: false
schema:
type: array
items:
type: string
default: 'a,b,c'
schema.getDefault()
returns "a,b,c"
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Empty list as default value in AVRO array - Stack Overflow
Using the Builder of the parsed avro Schema class would fill the "string_arr" field with an empty array per default. Save this answer....
Read more >Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. JSON data has the concept of null and empty arrays...
Read more >Handling NULL in Parse JSON - Power Platform Community
Solved: I have an API which has the following characteristics: Schema: ... any way to create a schema which allows null values in...
Read more >Writing a schema - FlatBuffers - Google
Only scalar values can have defaults, non-scalar (string/vector/table) fields default to NULL when not present. You generally do not want to change default...
Read more >Setting default values in the schema of a component in a Job
You can set default values in the schema of certain components to replace null values retrieved from the data source. Note: At present,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s where it gets complicated. Not sure there is a way to do it, as it’s an edge case.
Theoretically, you could set the default value to
[]
which is indeed an empty JSON array. However, the value of the array in this case is not a JSON, especially with the defaults for query parameters havingstyle: form
,explode: true
by default - suggesting there’s no real way of representing that. I’d recommend filing a ticket on the spec asking that question. We may simply agree that a JSON array value would be representative of such values regardless of how those are being converted to the request.That said, in your specific example, one might argue that there’s no point providing a default value of an empty array as it most likely does not affect the documentation nor implementation.
Hi, the scope of the issue changed, the validation of this new scope made in another PR. Thanks @jason-cohen for reporting this and sorry for the long reply. I will close this because is no longer an issue.