OpenAPITools / OpenAPITools/openapi-generator
[BUG][Spring] Enum value is ignored for path and query params
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
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
When a path or query param has enum constraint, it is generated as String.
We need to generate it as an enum.
openapi-generator version
Last from master
OpenAPI declaration file content or url
---
openapi: "3.0.1"
info:
title: "My Little Pony"
description: "Friendship is magic"
contact: {}
version: "1.0.0"
paths:
/ponies:
summary: "Everything for ponies"
get:
summary: "List"
operationId: "list"
parameters:
- name: "name"
in: "query"
required: false
schema:
type: "string"
enum:
- "Big McIntosh"
- "Rainbow Dash"
- "Pinkie Pie"
- "Rarity"
responses:
200:
description: "Status 200"
content:
application/json:
schema:
type: "array"
items:
$ref: "#/components/schemas/Pony"
400:
description: "Status 400"
components:
schemas:
Pony:
type: "object"
properties:
Id:
type: "string"
Generation Details
Spring generator with spring-boot library
https://github.com/OpenAPITools/openapi-generator/blob/master/bin/configs/spring-boot-delegate.yaml
Steps to reproduce
Related issues/PRs
Suggest a fix
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.
Research direction
Start with the Spring spring-boot generator configuration at bin/configs/spring-boot-delegate.yaml and the supplied OpenAPI declaration. Inspect how its path and query parameters are generated, then compare the enum parameter output with the expected enum type; done means enum-constrained parameters are no longer generated as String.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100