-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Closed
Copy link
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Default value tags for arrays have square braces([]) surrounded on them, which would fail because of invalid enum values.
Initial state:
openapi.yaml
openapi: 3.0.3
info:
version: 1.0.0
title: Bug Report
description: Spring generator, array enums
paths:
/test:
$ref: 'file.yaml#/paths/~1test'
file.yaml
components:
parameters:
pets:
name: pets
in: query
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default: [DOG, FISH]
schemas:
Pet:
type: string
enum:
- DOG
- CAT
- FISH
paths:
/test:
get:
description: Returns ad for a given ad ID.
operationId: getAd
parameters:
- $ref: '#/components/parameters/pets'
responses:
'200':
description: OK
content:
text/plain:
schema:
type: string
example: pong
Command Run:
openapi-generator generate -i openapi.yaml -g spring
Actual output:
default ResponseEntity<String> getAd(
@Parameter(name = "pets", description = "", in = ParameterIn.QUERY) @Valid
@RequestParam(value = "pets", required = false, defaultValue = "[DOG, FISH]") List<Pet> pets
)
Expected Output:
default ResponseEntity<String> getAd(
@Parameter(name = "pets", description = "", in = ParameterIn.QUERY) @Valid
@RequestParam(value = "pets", required = false, defaultValue = "DOG, FISH") List<Pet> pets
)
Actual output makes spring think that [DOG and FISH] are the provided enums and would fail the request processing.
openapi-generator version
openapi-generator-cli 6.6.0
commit : 7f8b853
built : -999999999-01-01T00:00:00+18:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
Debug info
This bug would not occur if the paths are in the main openapi.yaml file instead of being referenced from the file.yaml
Reactions are currently unavailable