swagger-api / swagger-api/swagger-parser
Default value of array type is not converted correctly when converting from swagger 2 to openapi 3,
Open
@gracekarina is already working on this.
Since Mar 15, 2023.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Q&A
- OS: [macOS]
- Browser: [chrome]
- Version: [108.0.5359.124 (Official Build) (arm64)]
- Method of installation: [docker]
- Swagger-Editor version: ["4.14.0"]
- Swagger/OpenAPI version: [Swagger 2.0 -> OpenAPI 3.0]
Content & configuration
Example Swagger ver2.0 definition (Before conversion):
swagger: '2.0'
info:
title: Future Vuls Public API
description: Future Vuls Public API
contact:
name: FutureVuls
url: >-
https://xxxxxxxxxxxxxxxxxxx
version: v1
host: host.xxxx.biz
schemes:
- https
paths:
/items:
get:
parameters:
- name: status filter
in: query
description: Status filter
required: false
type: array
items:
type: string
enum:
- new
- investigating
- ongoing
- defer
- not_affected
- risk_accepted
- workaround
- patch_applied
collectionFormat: multi
default: # array type
- new
- investigating
- ongoing
responses:
'200':
description: OK response.
Example OpenAPI ver3.0 definition (after conversion):
openapi: 3.0.1
info:
title: Future Vuls Public API
description: Future Vuls Public API
contact:
name: FutureVuls
url: https://xxxxxxxxxxxxxxxxxxx
version: v1
servers:
- url: https://host.xxxx.biz/
paths:
/items:
get:
parameters:
- name: status filter
in: query
description: Status filter
style: form
explode: true
schema:
type: array
items:
type: string
enum:
- new
- investigating
- ongoing
- defer
- not_affected
- risk_accepted
- workaround
- patch_applied
default: '["new","investigating","ongoing"]' # Converted default value is not of type `array`
responses:
200:
description: OK response.
content: {}
components: {}
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior:
- import file (Example Swagger ver2.0 definition)
- Go to 'toolbar'
- Click on 'Edit' > 'convert to OpenAPI 3'
Expected behavior
Now
default: '["new","investigating","ongoing"]' # Converted default value is not of type `array`
Correct output
default:
- new
- investigating
- ongoing
Additional context or thoughts
It would be more appreciated that an error is displayed if the type is array but the default value is of any other type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.