swagger-api / swagger-api/swagger-codegen
Code generator - enums are discarded
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I've only just begun using Swagger-editor, so maybe I'm doing something wrong.
Using this simple description
openapi: 3.0.0
info:
version: 0.0.1
title: Test enums
paths:
/products:
get:
summary: List all products
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Product'
components:
schemas:
Management:
type: array
items:
type: string
enum:
- Active
- Passive
Product:
type: object
properties:
id:
type: string
name:
type: string
management:
$ref: '#/components/schemas/Management'
required:
- id
- name
- management
What I get:
Scala:
case class Management (
)
What I expect:
Scala:
sealed trait Management
case object Active extends Management
case object Passive extends Management
I use Scala here because it's less verbose. But it seem to be the same for Java, C# and likely others.
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 by reproducing the issue with the supplied OpenAPI definition and compare the generated Scala output with the expected enum representation. Then trace the relevant language generator templates or entry points for Scala, Java, and C#; done means array-based enum schemas are preserved rather than emitted as empty classes across the affected generators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi, scala
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100