Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1997
Closed
Open
Issue created Jan 27, 2019 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] nullable enum property

Created by: rienafairefr

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? 3.3.0
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

If encountered this using the python but I feel like this is the case in a lot of cases I encountered an API that was publishing a 2.0 spec, but I'm getting resultst from the API that are out-of-spec and not possible to be parsed by a generate openapi-generator client, mostly sending null on non-nullable properties. But the issue is for enum values, I'm not sure how a client should validate:

a small spec that is apparently valid according to 3.0.2

openapi: 3.0.1
paths:
  /test:
    summary: test
info:
  description: test
  version: 1.0.0
  title: test
components:
  schemas:
    Type:
      properties:
        prop:
          nullable: true
          enum: [A, B, C]
          type: string

if the enum is nullable, then getting a null as a result data from an API call should be valid and we should get a property typed like Enum? in C#, or a None` value in Python, and that should be valid. But the code in the case of an enum lists the allowable values excluding null, even if the enum property is specified nullable

Suggest a fix
  • explicitely adding None in the allowed_values list in Python seems to at least make the client accept what the API sends, not sure if that's the full extent that a fix would take
Assignee
Assign to
Time tracking