swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[JAVASCRIPT]- Bug with js client code generation: Allof and Enum Inheritance

Open tomaValer opened this issue 3 years ago • 1 comments

Description
  • when i try to generate a javascript client from a YAML that has this schemas format
  1. an enum schema
  2. a schema that uses allof and ref for that enum the js client generated has a class that tries to extend an enum (that is represented as a const var in the generated client). and then when i try to use the client it fails with an error bootstrap:27 Uncaught TypeError: Class extends value #<Object> is not a constructor or null at ./javascript-client-generated/src/model/AllOfPossibleIssueMode.js (AllOfPossibleIssueMode.js:24:1) at options.factory (react refresh:6:1) at __webpack_require__ (bootstrap:24:1) at fn (hot module replacement:62:1) at ./javascript-client-generated/src/index.js (UserApi.js:367:1) at options.factory (react refresh:6:1) at __webpack_require__ (bootstrap:24:1) at fn (hot module replacement:62:1) at ./src/App.js (logo.svg:30:1) at options.factory (react refresh:6:1)
Swagger-codegen version

using the online client generator (from swagger editor)

Swagger declaration file content or url
  • easy to recreate with the pet store example and adding the following schemas (even without referencing them)
components:
  schemas:
    PossibleIssueEnum:
      title: "PossibleIssueEnum"
      enum:
      - "issue1"
      - "issue2"
      description: "An enumeration."
      
    PossibleIssue:
      title: "PossibleIssue"
      required:
      - "mode"
      type: "object"
      properties:
        mode:
          type: "string"
          allOf:
          - $ref: "#/components/schemas/PossibleIssueEnum"
          description: "possible issues.\
            \ Possible options: “issue1” / “issue2”"
Steps to reproduce
  • add the following schemas to the pet store example
  • generate a js client
  • try to use any endpoint
Related issues/PRs

tomaValer avatar Nov 29 '22 10:11 tomaValer

Is this show-stopper working in progress?

onacit avatar Nov 03 '23 07:11 onacit