Open
Description
openapi-typescript version
7.8.0
Node.js version
22.14.0
OS + version
macOS 15.5
Description
I am having troubles find out how to use a schema $ref object within query parameters.
They below example is simplified from https://freamon.github.io/piefed-api/ where the problem can be reproduced.
I would expect the $ref object to be spread onto the type. For example,
query?: components["schemas"]["Foo"] & components["schemas"]["Bar"] & components["schemas"]["Baz"];
Instead I get something like:
query?: {
Foo?: components["schemas"]["Foo"];
Bar?: components["schemas"]["Bar"];
Baz?: components["schemas"]["Baz"];
};
Reproduction
Input
openapi: 3.1.1
info:
version: 1.0.0
title: Test
servers:
- url: https://piefed.social/api/alpha
security:
- bearerAuth: []
paths:
/post/list:
get:
summary: Get posts
parameters:
- name: GetPosts
in: query
explode: true
schema:
$ref: "#/components/schemas/GetPosts"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
GetPosts:
properties:
page:
title: GetPosts.page
type: integer
limit:
title: GetPosts.limit
type: integer
additionalProperties: false
title: GetPosts
type: object
Output
/**
* This file was auto-generated by openapi-typescript.
* Do not make direct changes to the file.
*/
export interface paths {
"/post/list": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Get posts */
get: {
parameters: {
query?: {
GetPosts?: components["schemas"]["GetPosts"];
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: never;
};
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
schemas: {
/** GetPosts */
GetPosts: {
/** GetPosts.page */
page?: number;
/** GetPosts.limit */
limit?: number;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type $defs = Record<string, never>;
export type operations = Record<string, never>;
### Expected result
Actual:
```ts
query?: {
GetPosts?: components["schemas"]["GetPosts"];
};
Expected:
query?: components["schemas"]["GetPosts"];
Note that when loading in Swagger playground, the test request properly executes.
Required
- My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint
)
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)