swagger-api / swagger-api/swagger-codegen

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

Open
#12,401 0 comments 0 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

我是一名前端开发者,非常喜欢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

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.1 schema and reproduce generation through the generator3.swagger.io service using the typescript-axios generator. Investigate how the Map«string,string» schema with additionalProperties is handled; done means the example generates Typescript-Axios code without the reported model-processing error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.