Closed
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Use enum in query string throws 400. EnumMember
attribute is not considered by validation.
openapi-generator version
4.1.0
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: Test
version: 0.1.0
servers:
- url: http://localhost
paths:
/:
get:
operationId: test
parameters:
- name: param
in: query
required: true
schema:
$ref: '#/components/schemas/EnumParam'
responses:
200:
description: test
components:
schemas:
EnumParam:
type: string
enum:
- apple
- orange
Command line used for generation
openapi-generator generate -g aspnetcore -o test -i openapi.yaml
Steps to reproduce
Call endpoint with query string ?param=apple
throws validation error 400.
Related issues/PRs
Suggest a fix
According to link
The reason you are getting that error is Json.NET isn't the library converting the enum so the EnumMember attributes are not being used. You can get around this by writing a TypeConverter and applying it to your enum:
Maybe add a TypeConverter or just name the enum members without Enum
suffix?