我的swagger.json包括以下模式:
"schemas": {
"BuildFruitBody": {
"properties": {
"id": {
"type": "number",
"format": "double"
},
"name": {
"type": "string"
}
},
"type": "object",
"additionalProperties": true
}
},
然而,当我通过生成axios客户端时
npx openapi-typescript-codegen -i ./swagger.json -o src/services/api -c axios
,得到的模型如下:
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type BuildFruitBody = Record<string, any>;
我是不是做错了什么?为什么模型不能反映模式?
下面是完整的swagger.json:
{
"components": {
"examples": {},
"headers": {},
"parameters": {},
"requestBodies": {},
"responses": {},
"schemas": {
"BuildFruitBody": {
"properties": {
"id": {
"type": "number",
"format": "double"
},
"name": {
"type": "string"
}
},
"type": "object",
"additionalProperties": true
}
},
"securitySchemes": {}
},
"info": {
"title": "backend",
"contact": {}
},
"openapi": "3.0.0",
"paths": {
"/swagger.json": {
"get": {
"operationId": "Get",
"responses": {
"200": {
"description": "Ok",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
},
"tags": [
"swagger"
],
"security": [],
"parameters": []
}
},
"/fruit": {
"post": {
"operationId": "Get",
"responses": {
"200": {
"description": "Ok",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
},
"tags": [
"fruit"
],
"security": [],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BuildFruitBody"
}
}
}
}
}
}
},
"servers": [
{
"url": "/"
}
]
}