open-api
open-api copied to clipboard
Case-insensitive enums
I have the following schema and I want to allow users to send body {"id": 123, "teamRole": "Admin"}
However right now openapi-request-validator will consider Admin invalid because it is not part of the enum choices.
I'm trying to find someway using the schema to coerce enums to the right casing.
So far I can't seem to find a way to achieve this with the provided tools in this repo and I feel like there really should be something available.
Any pointers appreciated
/teams/{teamId}/members:
post:
summary: "Add a member to a team"
requestBody:
description: "Member to add to team"
required: true
content:
application/json:
schema:
type: "object"
required:
- "id"
properties:
id:
type: "integer"
example: 963
description: "Global ID of the user"
teamRole:
type: "string"
enum:
- "ADMIN"
- "MEMBER"
example: "MEMBER"
responses:
201:
description: "Successfully added team member"
content:
application/json:
schema:
type: "object"
required:
- "id"
properties:
id:
type: "integer"
example: 963
description: "Global ID of the user"
parameters:
-
schema:
type: "integer"
name: "teamId"
in: "path"
required: true
description: "ID of the team"
example: "1"