Example fields being used as default values
See original GitHub issueWhen using a json based swagger document, example
values are being used a default
values when default
is not defined. The expectation is that example
values would be ignored.
For example:
"paths": {
"/companies": {
"post": {
"description": "Create a Company",
"parameters": [
{
"name": "company",
"in": "body",
"description": "A Company",
"required": true,
"schema": {
"$ref": "#/definitions/company"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/company"
}
},
"406": {
"description": "Not Acceptable"
}
}
}
}
},
"definitions": {
"company": {
"type": "object",
"properties": {
"id": {
"description": "unique identifier of a company",
"example": "01234567-89ab-cdef-0123-456789abcdef",
"format": "uuid",
"maxLength": 37,
"readOnly": true,
"type": "string"
},
"name": {
"description": "name of company",
"example": "acme",
"maxLength": 255,
"readOnly": false,
"type": "string"
},
"code": {
"description": "unique code of company",
"maxLength": 255,
"type": "string"
},
"created_at": {
"description": "when company was created",
"example": "2001-01-01T12:00:00Z",
"format": "date-time",
"readOnly": true,
"type": "string"
},
"updated_at": {
"description": "when company was updated",
"example": "2001-01-01T12:00:00Z",
"format": "date-time",
"readOnly": true,
"type": "string"
}
},
"required": [
"name",
"code"
]
}
}
When sending a POST request to the /companies
endpoint where the code
value is defined, but the name
field is empty. The result is the value acme
being used as if it were a default value.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Set default values for fields or controls - Microsoft Support
This article explains how to set a default value for a table field or for a control on a form in an Access...
Read more >Use a function to provide default field values | Sicse
A default value can be set for fields that are attached to a content type (i.e., any field-able entity). The entered value is...
Read more >Default Values and Placeholders - Formidable Forms
Default values will be used when a new entry is created or when a field is conditionally shown. Default values will not replace...
Read more >Default Field Values - Salesforce Help
Default field values automatically insert the value of a custom field when a new record is created. You can use a default value...
Read more >How to Add Default Values for Form Fields - WPForms
You can add a default value by typing text directly into the Default Value field. For our example, we'll add “General Inquiry” as...
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 FreeTop 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
Top GitHub Comments
😃
Thanks
This is still an issue, and a very bad bug?
https://github.com/APIDevTools/swagger-express-middleware/pull/99