Closed
Description
Description
generate file type error
code generate
const result = await openapiTS(this.schema, openAPITSOptions);
const schemaString = `${astToString(result)}`;
openapi.json
{
"openapi": "3.1.0",
"info": {
"title": "test",
"license": {
"name": "test"
},
"version": "0.4.1"
},
"tags": [
{
"name": "Test1",
"description": ""
}
],
"paths": {
"/root/v1/getQueryParams2": {
"get": {
"tags": ["Test1"],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code": {
"type": "number",
"description": "接口返回code码字段"
},
"data": {
"$ref": "#/components/schemas/commonResponse.2e0063f8"
},
"msg": {
"type": "string",
"description": "接口返回信息字段"
}
},
"required": ["code", "data"]
}
}
}
}
},
"parameters": [
{
"name": "inlineQueryParam5",
"in": "query",
"required": true,
"schema": {
"items": [
{
"type": "string"
},
{
"type": "boolean"
}
],
"type": "array",
"maxItems": 2,
"minItems": 2
}
},
{
"name": "inlineQueryParam6",
"in": "query",
"required": true,
"schema": {
"type": "array",
"items": {
"items": [
{
"type": "string"
},
{
"type": "boolean"
}
],
"type": "array",
"maxItems": 2,
"minItems": 2
}
}
},
{
"name": "inlineQueryParam7",
"in": "query",
"required": true,
"schema": {
"type": "array",
"items": {
"items": [
{
"items": [
{
"type": "string"
},
{
"type": "boolean"
}
],
"type": "array",
"maxItems": 2,
"minItems": 2
},
{
"type": "number"
}
],
"type": "array",
"maxItems": 2,
"minItems": 2
}
}
}
]
}
}
},
"components": {
"schemas": {
"commonResponse.2e0063f8": {
"type": "object",
"properties": {
"a": {
"type": "string"
}
},
"required": ["a"]
}
}
}
}
Name | Version |
---|---|
openapi-typescript |
7.0.0-next.5 |
Node.js | x.x.x |
OS + version | macOS 13, Windows 11, etc. |
Reproduction
generate error:
export interface paths {
'/root/v1/getQueryParams2': {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: {
parameters: {
query: {
inlineQueryParam5: [string, boolean];
inlineQueryParam6: [string, boolean];
inlineQueryParam7: [[string, boolean], number];
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Success */
200: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': {
/** @description 接口返回code码字段 */
code: number;
data: components['schemas']['commonResponse.2e0063f8'];
/** @description 接口返回信息字段 */
msg?: string;
};
};
};
};
};
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
schemas: {
'commonResponse.2e0063f8': {
a: string;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type $defs = Record<string, never>;
export type operations = Record<string, never>;
inlineQueryParam6 , inlineQueryParam7 type generater error!
should generater:
inlineQueryParam6: [string, boolean][];
inlineQueryParam7: [[string, boolean], number][];
when use V6 generator is ok!
Expected result
/**
* This file was auto-generated by @liangskyli/openapi-gen-ts.
* Do not make direct changes to the file.
*/
export interface paths {
'/root/v1/getQueryParams2': {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: {
parameters: {
query: {
inlineQueryParam5: [string, boolean];
inlineQueryParam6: [string, boolean][];
inlineQueryParam7: [[string, boolean], number][];
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Success */
200: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': {
/** @description 接口返回code码字段 */
code: number;
data: components['schemas']['commonResponse.2e0063f8'];
/** @description 接口返回信息字段 */
msg?: string;
};
};
};
};
};
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
schemas: {
'commonResponse.2e0063f8': {
a: string;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type $defs = Record<string, never>;
export type operations = Record<string, never>;
(in case it’s not obvious)
Checklist
- My OpenAPI schema passes the Redocly validator (
npx @redocly/cli@latest lint
) - I’m willing to open a PR (see CONTRIBUTING.md)