swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.72k stars 6.02k forks source link

[Typescript Axios] Bug generating Map or Map<String,String> Model #12401

Open Gengkaibo opened 1 month ago

Gengkaibo commented 1 month ago
Description

我是一名前端开发者,非常喜欢Swagger-Codegen带来的前端ts代码生成能力,我经常用来将后端接口文档的api-docs生成Typescript-Axios的代码,但是遇到了问题,当后端的Coltroller层返回值是Map的时候,Swagger-Codegen直接报错了(translate:I am a front-end developer and I really enjoy the front-end TS code generation capability brought by Swagger Codegen. I often use API docs in back-end interface documents to generate Typescript Axios code, but I encountered a problem. When the Coltroller layer in the backend returns a Map value, Swagger Codegen directly reports an error)

当尝试通过服务 'https://generator3.swagger.io/api/generate' 获取Typescript-Axios代码时,服务错误为:(translate:When attempting to access the service 'https://generator3.swagger.io/api/generate' When obtaining Typescript Axios code, the service error is:

Error generating typescript-axios code : Could not process model 'Map脗芦string,string脗禄'.Please make sure that your schema is correct!

Swagger-codegen version

Latest Version

Swagger declaration file content or url
openapi: 3.0.1
info:
  title: API测试文档
  description: 接口测试文档
  contact:
    name: beyourself
    url: https://blog.csdn.net/qq_27535933
    email: 310857864@qq.com
  version: v1.0
servers:
- url: //175.27.229.68:8086/dataAsset
tags:
- name: 数据资产管理
  description: Data Asset Controller
paths:
  /asset/queryList:
    post:
      tags:
      - 数据资产管理
      summary: 数据资产实例列表查询
      operationId: queryListUsingPOST
      requestBody:
        description: param
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PageParams«AssetInstanceParamer列表查询实体»'
        required: true
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/ReturnEntity'
      deprecated: false
      x-order: "2147483647"
      x-codegen-request-body-name: param
components:
  schemas:
    AssetInstanceParamer列表查询实体:
      title: AssetInstanceParamer列表查询实体
      type: object
      properties:
        costList:
          type: array
          description: 成本构成
          items:
            $ref: "#/components/schemas/Map«string,string»"
        createTimeEnd:
          type: string
        createTimeStart:
          type: string
        flowStatus:
          type: string
          description: //10A 通过  10B 驳回 10C 审批中 10D 草稿  不选 和全部不用穿
        flowableInstId:
          type: string
          description: 流程实例ID
        instanceName:
          type: string
          description: 实例名称
        sceneId:
          type: string
          description: 场景id
        updateTimeEnd:
          type: string
        updateTimeStart:
          type: string
        userId:
          type: string
        valuationMethods:
          type: string
          description: 估值方法
    Map«string,string»:
      title: "Map«string,string»"
      type: object
      additionalProperties:
        type: string
x-original-swagger-version: "2.0"
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement