Skip to content

[BUG][typescript-axios] Unnecessary imports occurs when using withSeparateModelsAndApi #5796

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

Closed
5 of 6 tasks
tanmen opened this issue Apr 2, 2020 · 3 comments · Fixed by #5797
Closed
5 of 6 tasks

Comments

@tanmen
Copy link
Contributor

tanmen commented Apr 2, 2020

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?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

If withSeparateModelsAndApi is used, it tries to import a model that is not used.
import must be used or deleted.

api response

target

            200:
              description: Box list
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/BoxesResponse'
            403:
              description: Forbidden
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/ForbiddenResponse'
openapi-generator version

4.3.0

OpenAPI declaration file content or url
OpenAPI schema

Schema
openapi: 3.0.2
info:
  title: My application
  version: 1.0.0
  description: My application
tags:
  - name: Box
paths:
  /boxes:
    get:
      summary: Box list
      description: Box list
      operationId: showBoxes
      tags:
        - Box
      responses:
        200:
          description: Box list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoxesResponse'
        403:
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenResponse'
components:
  schemas:
    Response:
      type: string
      example: success
      enum:
        - success
        - error
    Box:
      type: object
      properties:
        id:
          type: number
          example: 1
        name:
          type: string
          example: inbox
        box:
          $ref: '#/components/schemas/BoxInBox'
    BoxInBox:
      type: object
      properties:
        id:
          type: number
          example: 1
        name:
          type: string
          example: inbox
    BoxesResponse:
      allOf:
        - $ref: '#/components/schemas/Response'
        - $ref: '#/components/schemas/Box'
    ForbiddenResponse:
      type: object
      properties:
        status:
          type: number
          example: 403
        message:
          type: string
          example: please signin

Command line used for generation

openapi-generator generate -i openapi.yml -g typescript-axios -o apis -p withSeparateModelsAndApi=true --api-package apis --model-package models

Steps to reproduce

N/A

Related issues/PRs

N/A

Suggest a fix

#5797

@auto-labeler
Copy link

auto-labeler bot commented Apr 2, 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.

@amakhrov
Copy link
Contributor

amakhrov commented Apr 2, 2020

Is it a regression since the previously fixed #4804 ?

@tanmen
Copy link
Contributor Author

tanmen commented Apr 2, 2020

@amakhrov
no.
i fixed type error if multi response schema :)

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