swagger-api / swagger-api/swagger-codegen

[JavaScript] Missing `ModelObject` in JS

Open
#10,116 4 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When using a oneof with openapi: "3.0.0" the code generates an import inside the models folder for ./ModelObject. models/ModelObject.js is never generated.

Swagger-codegen version

3.0.18

Swagger declaration file content or url
    MyObject:
      title: MyObjectTitle
      type: object
      properties:
        messageType:
          type: string
        message:
          oneOf:
            - $ref: '#/components/schemas/MessageA'
            - $ref: '#/components/schemas/MessageB'
      required:
        - messageType
Command line used for generation

On OSX (installed via brew):

swagger-codegen generate --lang javascript --input my-spec.yml -o ./
Steps to reproduce

Create above model in a yaml file, run generation command, attempt to build project.

Related issues/PRs

N/A

Suggest a fix/enhancement

If we know what the outputted code should be I can shim this into our library to unblock us.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI 3.0.0 YAML and run the shown JavaScript generation command. Inspect the generated models directory and the import of ./ModelObject; done means the generated project builds without a missing ModelObject.js file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.