Skip to content

Create a test and example using enums. #110

@seriouslag

Description

@seriouslag
Collaborator

Is your feature request related to a problem? Please describe.
There are consumers of this library that use enums, we have no tests or examples showing their generation/usage.

Describe the solution you'd like
A unit test or snapshot showing their creation.

Describe alternatives you've considered
None,

Activity

sschuberth

sschuberth commented on May 12, 2024

@sschuberth

I also struggle to get back the behavior from version 0.5.3 which e.g. generated

export namespace CreateRepository {

    export enum type {
        GIT = 'GIT',
        GIT_REPO = 'GIT_REPO',
        MERCURIAL = 'MERCURIAL',
        SUBVERSION = 'SUBVERSION',
        CVS = 'CVS',
    }


}

instead of version 1.3.0 now generating

export type CreateRepository = {
    type: 'GIT' | 'GIT_REPO' | 'MERCURIAL' | 'SUBVERSION' | 'CVS';
    url: string;
};

Using --enums typescript does not seems to have any effect.

Edit: Here's an excerpt from the used API spec:

      "CreateRepository" : {
        "required" : [ "type", "url" ],
        "type" : "object",
        "properties" : {
          "type" : {
            "type" : "string",
            "enum" : [ "GIT", "GIT_REPO", "MERCURIAL", "SUBVERSION", "CVS" ]
          },
          "url" : {
            "type" : "string"
          }
        }
      },
sschuberth

sschuberth commented on May 12, 2024

@sschuberth

Using --enums typescript does not seems to have any effect.

Maybe this could be related to hey-api/openapi-ts#547?

seriouslag

seriouslag commented on May 12, 2024

@seriouslag
CollaboratorAuthor

Using --enums typescript does not seems to have any effect.

Maybe this could be related to hey-api/openapi-ts#547?

That does seem related.
When they patch @hey-api/openapi-ts, we will need to write some tests to determine whether it is safe to update in the future.

There are lots of moving parts.
We would appreciate the help if you have time to write tests that satisfy your use case.

Maybe fallback to an old version of this library until the new release of @hey-api/openapi-ts

primeapple

primeapple commented on May 13, 2024

@primeapple

The new version 0.44.0 of openapi-ts fixes this problem and generates enums again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sschuberth@seriouslag@primeapple

        Issue actions

          Create a test and example using enums. · Issue #110 · 7nohe/openapi-react-query-codegen