Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [typescript-fetch] nullable: true is not respected with enum #7745

Closed
5 of 6 tasks
berlysia opened this issue Oct 18, 2020 · 2 comments · Fixed by #7754
Closed
5 of 6 tasks

[BUG] [typescript-fetch] nullable: true is not respected with enum #7745

berlysia opened this issue Oct 18, 2020 · 2 comments · Fixed by #7754

Comments

@berlysia
Copy link
Contributor

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Enum properties declared in models or request parameters ignore nullable: true

openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: yay
  version: 1.0.0
  title: OpenAPI Petstore
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
  /fake/enum-request:
    get:
      operationId: fake-enum-request
      parameters:
        - name: nullable-string-enum
          in: query
          schema:
            type: string
            nullable: true
            enum:
              - one
              - two
              - three
        - name: nullable-number-enum
          in: query
          schema:
            type: number
            nullable: true
            enum:
              - 1
              - 2
              - 3
      responses:
        200:
          description: OK
components: 
  schemas:
    NullableClass:
      type: object
      properties:
        number_prop:
          type: number
          nullable: true
        string_prop:
          type: string
          nullable: true
        string_enum_nullable_prop:
          type: string
          enum:
            - one
            - two
            - three
          nullable: true
        number_enum_nullable_prop:
          type: number
          enum:
            - 1
            - 2
            - 3
          nullable: true
Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-fetch -o /local/lib
export interface FakeEnumRequestRequest {
   nullableStringEnum?: FakeEnumRequestNullableStringEnumEnum; // must be nullable
   nullableNumberEnum?: FakeEnumRequestNullableNumberEnumEnum; // must be nullable
}
export interface NullableClass {
   /**
    *
    * @type {number}
    * @memberof NullableClass
    */
   numberProp?: number | null;
   /**
    *
    * @type {string}
    * @memberof NullableClass
    */
   stringProp?: string | null;
   /**
    *
    * @type {string}
    * @memberof NullableClass
    */
   stringEnumNullableProp?: NullableClassStringEnumNullablePropEnum; // must be nullable
   /**
    *
    * @type {number}
    * @memberof NullableClass
    */
   numberEnumNullableProp?: NullableClassNumberEnumNullablePropEnum; // must be nullable
}
Steps to reproduce

same as above

Related issues/PRs

Enum is supported by #665

Suggest a fix
@auto-labeler
Copy link

auto-labeler bot commented Oct 18, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@berlysia berlysia changed the title [BUG] [typescript-fetch] client cannot deal with nullable enum [BUG] [typescript-fetch] nullable: true is not respected with enum Oct 18, 2020
@macjohnny
Copy link
Member

@berlysia would you like to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants