Description
We have the following folder structure:
- openapi.json
- products
-- firstEndpoint.json
-- secondEndpoint.json
- schemas
-- FirstRequest.json
-- SecondRequest.json
-- SomeField.json
with:
openapi.json
{
"openapi": "3.0.3",
"info": {
"title": "API",
"version": "1.0.0"
},
"paths": {
"/firstEndpoint": {
"$ref": "products/firstEndpoint.json"
},
"/secondEndpoint": {
"$ref": "products/secondEndpoint.json"
}
}
}
firstEndpoint.json
{
"post": {
"operationId": "testOne",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "schemas/FirstRequest.json"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
secondEndpoint.json
{
"post": {
"operationId": "testTwo",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "schemas/SecondRequest.json"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
FirstRequest.json
{
"type": "object",
"properties": {
"someField": {
"$ref": "SomeField.json"
}
}
}
SecondRequest.json
{
"type": "object",
"properties": {
"someField": {
"$ref": "SomeField.json"
}
}
}
SomeField.json
{
"type": "object",
"properties": {
"someProperty": {
"type": "string"
}
}
}
The problem is, that the types.gen.ts generates the first reference on SomeField.json in FirstRequest.json correctly but can not resolve the same reference in SecondRequest.json:
types.gen.ts
export type TestOneData = {
requestBody: {
someField?: {
someProperty?: string;
};
};
};
export type TestTwoData = {
requestBody: {
someField?: paths__1firstEndpoint_post_requestBody_content_application_1json_schema_properties_someField; // <-- this does not compile
};
};
OpenAPI specification (optional)
No response
Configuration
import { defineConfig } from '@hey-api/openapi-ts';
export default defineConfig({
input: '../openapi/openapi-test.json',
output: {
path: 'src/client',
format: 'prettier'
},
debug: true
});
System information (optional)
npm 10.7.0
Node 20.14.0
openapi-ts 0.46.3
Description
We have the following folder structure:
with:
openapi.json
{ "openapi": "3.0.3", "info": { "title": "API", "version": "1.0.0" }, "paths": { "/firstEndpoint": { "$ref": "products/firstEndpoint.json" }, "/secondEndpoint": { "$ref": "products/secondEndpoint.json" } } }firstEndpoint.json
{ "post": { "operationId": "testOne", "requestBody": { "content": { "application/json": { "schema": { "$ref": "schemas/FirstRequest.json" } } }, "required": true }, "responses": { "200": { "description": "OK" } } } }secondEndpoint.json
{ "post": { "operationId": "testTwo", "requestBody": { "content": { "application/json": { "schema": { "$ref": "schemas/SecondRequest.json" } } }, "required": true }, "responses": { "200": { "description": "OK" } } } }FirstRequest.json
{ "type": "object", "properties": { "someField": { "$ref": "SomeField.json" } } }SecondRequest.json
{ "type": "object", "properties": { "someField": { "$ref": "SomeField.json" } } }SomeField.json
{ "type": "object", "properties": { "someProperty": { "type": "string" } } }The problem is, that the
types.gen.tsgenerates the first reference onSomeField.jsoninFirstRequest.jsoncorrectly but can not resolve the same reference inSecondRequest.json:types.gen.ts
OpenAPI specification (optional)
No response
Configuration
System information (optional)
npm 10.7.0
Node 20.14.0
openapi-ts 0.46.3