Skip to content

Commit b7b47e9

Browse files
committed
fix: add header and response IR kinds, parse components/responses, add 3.1.x test
- Add `header` and `response` as separate top-level IR kinds instead of expanding the `schema` regex pattern - Parse `components/responses` in both 3.0.x and 3.1.x parsers - Add `responses` to `IRComponentsObject` type - Update `WalkEvents` union and `forEach` switch for new event types - Subscribe `@hey-api/typescript` plugin to `header` and `response` events - Create `components-headers.yaml` spec for 3.1.x (with both headers and responses) - Update 3.0.x spec to follow naming conventions and include responses - Convert `parseSchema`/`parseHeader` to `function` syntax - Update graph unit tests for new patterns
1 parent a3b88dc commit b7b47e9

28 files changed

Lines changed: 394 additions & 34 deletions

File tree

packages/openapi-ts-tests/main/test/3.0.x.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe(`OpenAPI ${version}`, () => {
156156
input: 'components-headers.yaml',
157157
output: 'components-headers',
158158
}),
159-
description: 'handles reusable header components',
159+
description: 'handles reusable header and response components',
160160
},
161161
{
162162
config: createConfig({

packages/openapi-ts-tests/main/test/3.1.x.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ describe(`OpenAPI ${version}`, () => {
171171
}),
172172
description: 'handles snake_case identifier casing',
173173
},
174+
{
175+
config: createConfig({
176+
input: 'components-headers.yaml',
177+
output: 'components-headers',
178+
}),
179+
description: 'handles reusable header and response components',
180+
},
174181
{
175182
config: createConfig({
176183
input: 'components-request-bodies.json',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type { ClientOptions, Foo, GetFooData, GetFooResponse, GetFooResponses, XRateLimit } from './types.gen';
3+
export type { ClientOptions, Foo, GetFooData, GetFooResponse, GetFooResponses, NotFound, XRateLimit } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-headers/types.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ export type ClientOptions = {
66

77
export type XRateLimit = number;
88

9+
/**
10+
* Resource not found
11+
*/
12+
export type NotFound = {
13+
code?: number;
14+
message?: string;
15+
};
16+
917
export type Foo = {
1018
rateLimit?: XRateLimit;
1119
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type { _1, ClientOptions, Deep, ExternalAllOfSchema, ExternalAnyOfSchema, ExternalArraySchema, ExternalDeepHeader, ExternalDeepParam, ExternalDoubleNestedNumeric, ExternalDoubleNestedProp, ExternalIdHeader, ExternalIdParam, ExternalMixedBody, ExternalMixedProperties, ExternalModelBody, ExternalNested, ExternalNestedBody, ExternalNestedNumeric, ExternalNestedNumericObjectA, ExternalNestedNumericObjectB, ExternalNestedObjectA, ExternalNestedObjectB, ExternalNumericParam, ExternalSchemaA, ExternalSchemaB, ExternalSchemaC, ExternalSchemaExternalProp, ExternalSchemaExternalPropAlias, ExternalSchemaPathA, ExternalSchemaPathB, ExternalSchemaPropertyA, ExternalSchemaPropertyB, ExternalSchemaPropertyC, ExternalSchemaPropertyD, ExternalSharedModel, ExternalSharedModelWithUuid, ExternalUnionSchema, ExternalUuidBody, ExternalUuidHeader, ExternalUuidParam, GetExternalArrayData, GetExternalArrayResponse, GetExternalArrayResponses, GetExternalMixedData, GetExternalMixedResponse, GetExternalMixedResponses, GetExternalModelData, GetExternalModelError, GetExternalModelErrors, GetExternalModelResponse, GetExternalModelResponses, GetExternalNestedData, GetExternalNestedResponse, GetExternalNestedResponses, GetExternalPropertiesByIdData, GetExternalPropertiesByIdResponse, GetExternalPropertiesByIdResponses, GetExternalUnionData, GetExternalUnionResponse, GetExternalUnionResponses, GetExternalUuidData, GetExternalUuidResponse, GetExternalUuidResponses, Id, Name, PostExternalArrayData, PostExternalArrayResponse, PostExternalArrayResponses, PostExternalMixedData, PostExternalMixedResponse, PostExternalMixedResponses, PostExternalModelData, PostExternalModelError, PostExternalModelErrors, PostExternalModelResponse, PostExternalModelResponses, PostExternalNestedData, PostExternalNestedResponse, PostExternalNestedResponses, PostExternalUnionData, PostExternalUnionResponse, PostExternalUnionResponses, PutExternalUuidData, PutExternalUuidResponse, PutExternalUuidResponses } from './types.gen';
3+
export type { _1, ClientOptions, Deep, ExternalAllOfSchema, ExternalAnyOfSchema, ExternalArrayResponse, ExternalArraySchema, ExternalDeepHeader, ExternalDeepParam, ExternalDoubleNestedNumeric, ExternalDoubleNestedProp, ExternalIdHeader, ExternalIdParam, ExternalMixedBody, ExternalMixedProperties, ExternalModelBody, ExternalModelResponse, ExternalNested, ExternalNestedBody, ExternalNestedNumeric, ExternalNestedNumericObjectA, ExternalNestedNumericObjectB, ExternalNestedObjectA, ExternalNestedObjectB, ExternalNestedResponse, ExternalNumericParam, ExternalSchemaA, ExternalSchemaB, ExternalSchemaC, ExternalSchemaExternalProp, ExternalSchemaExternalPropAlias, ExternalSchemaPathA, ExternalSchemaPathB, ExternalSchemaPropertyA, ExternalSchemaPropertyB, ExternalSchemaPropertyC, ExternalSchemaPropertyD, ExternalSharedModel, ExternalSharedModelWithUuid, ExternalUnionResponse, ExternalUnionSchema, ExternalUuidBody, ExternalUuidHeader, ExternalUuidParam, ExternalUuidResponse, GetExternalArrayData, GetExternalArrayResponse, GetExternalArrayResponses, GetExternalMixedData, GetExternalMixedResponse, GetExternalMixedResponses, GetExternalModelData, GetExternalModelError, GetExternalModelErrors, GetExternalModelResponse, GetExternalModelResponses, GetExternalNestedData, GetExternalNestedResponse, GetExternalNestedResponses, GetExternalPropertiesByIdData, GetExternalPropertiesByIdResponse, GetExternalPropertiesByIdResponses, GetExternalUnionData, GetExternalUnionResponse, GetExternalUnionResponses, GetExternalUuidData, GetExternalUuidResponse, GetExternalUuidResponses, Id, Name, PostExternalArrayData, PostExternalArrayResponse, PostExternalArrayResponses, PostExternalMixedData, PostExternalMixedResponse, PostExternalMixedResponses, PostExternalModelData, PostExternalModelError, PostExternalModelErrors, PostExternalModelResponse, PostExternalModelResponses, PostExternalNestedData, PostExternalNestedResponse, PostExternalNestedResponses, PostExternalUnionData, PostExternalUnionResponse, PostExternalUnionResponses, PutExternalUuidData, PutExternalUuidResponse, PutExternalUuidResponses } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/types.gen.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ export type ExternalUuidHeader = ExternalSharedModelWithUuid;
1010

1111
export type ExternalDeepHeader = Deep;
1212

13+
/**
14+
* Response using external model
15+
*/
16+
export type ExternalModelResponse = ExternalSharedModel;
17+
18+
/**
19+
* Response using external UUID
20+
*/
21+
export type ExternalUuidResponse = ExternalSharedModelWithUuid;
22+
23+
/**
24+
* Response using external nested object
25+
*/
26+
export type ExternalNestedResponse = ExternalNested;
27+
28+
/**
29+
* Response with array of external models
30+
*/
31+
export type ExternalArrayResponse = Array<ExternalSharedModel>;
32+
33+
/**
34+
* Response with union of external types
35+
*/
36+
export type ExternalUnionResponse = ExternalSharedModel | ExternalSharedModelWithUuid | ExternalNested;
37+
1338
export type _1 = string;
1439

1540
export type ExternalSchemaA = ExternalSharedModel;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
export type { ClientOptions, Foo, GetFooData, GetFooResponse, GetFooResponses, NotFound, XRateLimit } from './types.gen';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
export type ClientOptions = {
4+
baseUrl: `${string}://${string}` | (string & {});
5+
};
6+
7+
export type XRateLimit = number;
8+
9+
/**
10+
* Resource not found
11+
*/
12+
export type NotFound = {
13+
code?: number;
14+
message?: string;
15+
};
16+
17+
export type Foo = {
18+
rateLimit?: XRateLimit;
19+
};
20+
21+
export type GetFooData = {
22+
body?: never;
23+
path?: never;
24+
query?: never;
25+
url: '/foo';
26+
};
27+
28+
export type GetFooResponses = {
29+
/**
30+
* OK
31+
*/
32+
200: Foo;
33+
};
34+
35+
export type GetFooResponse = GetFooResponses[keyof GetFooResponses];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type { _1, ClientOptions, Deep, ExternalAllOfSchema, ExternalAnyOfSchema, ExternalArraySchema, ExternalDeepHeader, ExternalDeepParam, ExternalDoubleNestedNumeric, ExternalDoubleNestedProp, ExternalIdHeader, ExternalIdParam, ExternalMixedBody, ExternalMixedProperties, ExternalModelBody, ExternalNested, ExternalNestedBody, ExternalNestedNumeric, ExternalNestedNumericObjectA, ExternalNestedNumericObjectB, ExternalNestedObjectA, ExternalNestedObjectB, ExternalNumericParam, ExternalSchemaA, ExternalSchemaB, ExternalSchemaC, ExternalSchemaExternalProp, ExternalSchemaExternalPropAlias, ExternalSchemaPathA, ExternalSchemaPathB, ExternalSchemaPropertyA, ExternalSchemaPropertyB, ExternalSchemaPropertyC, ExternalSchemaPropertyD, ExternalSharedModel, ExternalSharedModelWithUuid, ExternalUnionSchema, ExternalUuidBody, ExternalUuidHeader, ExternalUuidParam, GetExternalArrayData, GetExternalArrayResponse, GetExternalArrayResponses, GetExternalMixedData, GetExternalMixedResponse, GetExternalMixedResponses, GetExternalModelData, GetExternalModelError, GetExternalModelErrors, GetExternalModelResponse, GetExternalModelResponses, GetExternalNestedData, GetExternalNestedResponse, GetExternalNestedResponses, GetExternalPropertiesByIdData, GetExternalPropertiesByIdResponse, GetExternalPropertiesByIdResponses, GetExternalUnionData, GetExternalUnionResponse, GetExternalUnionResponses, GetExternalUuidData, GetExternalUuidResponse, GetExternalUuidResponses, Id, Name, PostExternalArrayData, PostExternalArrayResponse, PostExternalArrayResponses, PostExternalMixedData, PostExternalMixedResponse, PostExternalMixedResponses, PostExternalModelData, PostExternalModelError, PostExternalModelErrors, PostExternalModelResponse, PostExternalModelResponses, PostExternalNestedData, PostExternalNestedResponse, PostExternalNestedResponses, PostExternalUnionData, PostExternalUnionResponse, PostExternalUnionResponses, PutExternalUuidData, PutExternalUuidResponse, PutExternalUuidResponses } from './types.gen';
3+
export type { _1, ClientOptions, Deep, ExternalAllOfSchema, ExternalAnyOfSchema, ExternalArrayResponse, ExternalArraySchema, ExternalDeepHeader, ExternalDeepParam, ExternalDoubleNestedNumeric, ExternalDoubleNestedProp, ExternalIdHeader, ExternalIdParam, ExternalMixedBody, ExternalMixedProperties, ExternalModelBody, ExternalModelResponse, ExternalNested, ExternalNestedBody, ExternalNestedNumeric, ExternalNestedNumericObjectA, ExternalNestedNumericObjectB, ExternalNestedObjectA, ExternalNestedObjectB, ExternalNestedResponse, ExternalNumericParam, ExternalSchemaA, ExternalSchemaB, ExternalSchemaC, ExternalSchemaExternalProp, ExternalSchemaExternalPropAlias, ExternalSchemaPathA, ExternalSchemaPathB, ExternalSchemaPropertyA, ExternalSchemaPropertyB, ExternalSchemaPropertyC, ExternalSchemaPropertyD, ExternalSharedModel, ExternalSharedModelWithUuid, ExternalUnionResponse, ExternalUnionSchema, ExternalUuidBody, ExternalUuidHeader, ExternalUuidParam, ExternalUuidResponse, GetExternalArrayData, GetExternalArrayResponse, GetExternalArrayResponses, GetExternalMixedData, GetExternalMixedResponse, GetExternalMixedResponses, GetExternalModelData, GetExternalModelError, GetExternalModelErrors, GetExternalModelResponse, GetExternalModelResponses, GetExternalNestedData, GetExternalNestedResponse, GetExternalNestedResponses, GetExternalPropertiesByIdData, GetExternalPropertiesByIdResponse, GetExternalPropertiesByIdResponses, GetExternalUnionData, GetExternalUnionResponse, GetExternalUnionResponses, GetExternalUuidData, GetExternalUuidResponse, GetExternalUuidResponses, Id, Name, PostExternalArrayData, PostExternalArrayResponse, PostExternalArrayResponses, PostExternalMixedData, PostExternalMixedResponse, PostExternalMixedResponses, PostExternalModelData, PostExternalModelError, PostExternalModelErrors, PostExternalModelResponse, PostExternalModelResponses, PostExternalNestedData, PostExternalNestedResponse, PostExternalNestedResponses, PostExternalUnionData, PostExternalUnionResponse, PostExternalUnionResponses, PutExternalUuidData, PutExternalUuidResponse, PutExternalUuidResponses } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/types.gen.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ export type ExternalUuidHeader = ExternalSharedModelWithUuid;
1010

1111
export type ExternalDeepHeader = Deep;
1212

13+
/**
14+
* Response using external model
15+
*/
16+
export type ExternalModelResponse = ExternalSharedModel;
17+
18+
/**
19+
* Response using external UUID
20+
*/
21+
export type ExternalUuidResponse = ExternalSharedModelWithUuid;
22+
23+
/**
24+
* Response using external nested object
25+
*/
26+
export type ExternalNestedResponse = ExternalNested;
27+
28+
/**
29+
* Response with array of external models
30+
*/
31+
export type ExternalArrayResponse = Array<ExternalSharedModel>;
32+
33+
/**
34+
* Response with union of external types
35+
*/
36+
export type ExternalUnionResponse = ExternalSharedModel | ExternalSharedModelWithUuid | ExternalNested;
37+
1338
export type _1 = string;
1439

1540
/**

0 commit comments

Comments
 (0)