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

[typescript-axios] incorrect imports in graph-like structures #1163

Open
programmer106 opened this issue Jun 2, 2023 · 4 comments
Open

[typescript-axios] incorrect imports in graph-like structures #1163

programmer106 opened this issue Jun 2, 2023 · 4 comments

Comments

@programmer106
Copy link

given:

components: 
  schemas: 
     Category:
      x-swagger-router-model: io.swagger.petstore.model.Category
      properties:
        id:
          type: string
        name:
          type: string
          example: Dogs
        subcategories:
          type: array,
          items:
            $ref: '#/components/schemas/Category'
      xml:
        name: category
      type: object

after generation:

/* tslint:disable */
/* eslint-disable */
/**
 * Swagger Petstore - OpenAPI 3.0
 * This is a sample Pet Store Server based on the OpenAPI 3.0 specification.  You can find out more about Swagger at [http://swagger.io](http://swagger.io). In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3. Some useful links: - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore) - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
 *
 * OpenAPI spec version: 1.0.17
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */
import { Category } from './category';
/**
 * 
 * @export
 * @interface Category
 */
export interface Category {
    /**
     * 
     * @type {string}
     * @memberof Category
     */
    id?: string;
    /**
     * 
     * @type {string}
     * @memberof Category
     */
    name?: string;
    /**
     * 
     * @type {Array<Category>}
     * @memberof Category
     */
    subcategories?: Array<Category>;
}

after trying to build got:

models/category.ts:14:10 - error TS2440: Import declaration conflicts with local declaration of 'Category'.

Can't maintain the client-ts layer effectively due to this issue.

@alemjimer
Copy link

Hi,
did you get a solution for this issue?

Thanks

@elkeis
Copy link

elkeis commented Mar 21, 2024

Hi,

did you get a solution for this issue?

Thanks

Eh, no.
Got fired.

@JohannesRiegler
Copy link

The same issue occured in the Angular TypeScript client swagger-api/swagger-codegen#6201.
It has already been fixed in swagger-api/swagger-codegen#6450.
Maybe a similar change for the axios client would fix the issue?

@Nexiz15
Copy link

Nexiz15 commented Aug 13, 2024

It is quiet hacky but you can simply duplicate your DTO:

components: 
  schemas: 
     Category:
       x-swagger-router-model: io.swagger.petstore.model.Category
       properties:
         id:
           type: string
         name:
           type: string
           example: Dogs
         subcategories:
           type: array,
           items:
             $ref: '#/components/schemas/CategoryRecurstion'
       xml:
         name: category
       type: object
     CategoryRecurstion:
       x-swagger-router-model: io.swagger.petstore.model.CategoryRecurstion
       properties:
         id:
           type: string
         name:
           type: string
           example: Dogs
         subcategories:
           type: array,
           items:
             $ref: '#/components/schemas/Category'
       xml:
         name: categoryRecursion
       type: object


JohannesRiegler added a commit to JohannesRiegler/swagger-codegen-generators that referenced this issue Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants