[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