Skip to content

Commit 9f00629

Browse files
authored
Merge pull request #3715 from hey-api/fix/spec-types
Fix/spec types
2 parents 05207e0 + b4a8afe commit 9f00629

18 files changed

Lines changed: 225 additions & 187 deletions

File tree

.changeset/clear-toes-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/spec-types": patch
3+
---
4+
5+
**types**: fix: use mutable arrays

.changeset/deep-paws-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/spec-types": minor
3+
---
4+
5+
**BREAKING**: rename `OpenAPIExtensions` to `SpecExtensions`

.changeset/olive-sides-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/spec-types": minor
3+
---
4+
5+
**BREAKING**: remove OpenAPI types from JSON Schema documents

.changeset/short-walls-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/spec-types": patch
3+
---
4+
5+
**openapi**: fix: stricter 2.0 version type

packages/shared/src/ir/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-namespace */
22
import type { Symbol } from '@hey-api/codegen-core';
3-
import type { JSONSchemaDraft2020_12, OpenAPIExtensions, OpenAPIV3_1 } from '@hey-api/spec-types';
3+
import type { JSONSchemaDraft2020_12, OpenAPIV3_1, SpecExtensions } from '@hey-api/spec-types';
44

55
import type { IRMediaType } from './mediaType';
66

@@ -22,7 +22,7 @@ interface IRComponentsObject {
2222
schemas?: Record<string, IRSchemaObject>;
2323
}
2424

25-
export interface IROperationObject extends OpenAPIExtensions {
25+
export interface IROperationObject extends SpecExtensions {
2626
body?: IRBodyObject;
2727
deprecated?: boolean;
2828
description?: string;
@@ -46,7 +46,7 @@ export interface IRParametersObject {
4646
}
4747

4848
export interface IRParameterObject
49-
extends Pick<JSONSchemaDraft2020_12.Document, 'deprecated' | 'description'>, OpenAPIExtensions {
49+
extends Pick<JSONSchemaDraft2020_12.Document, 'deprecated' | 'description'>, SpecExtensions {
5050
/**
5151
* Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of `contentType` (implicit or explicit) SHALL be ignored.
5252
*/
@@ -130,9 +130,9 @@ export interface IRSchemaObject
130130
| 'pattern'
131131
| 'required'
132132
| 'title'
133-
| 'example'
134133
>,
135-
OpenAPIExtensions {
134+
Pick<OpenAPIV3_1.SchemaObject, 'example'>,
135+
SpecExtensions {
136136
/**
137137
* If the schema is intended to be used as an object property, it can be
138138
* marked as read-only or write-only. This value controls whether the schema

packages/spec-types/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
],
3838
"type": "module",
3939
"sideEffects": false,
40-
"types": "./dist/index.d.ts",
40+
"types": "./dist/index.d.mts",
4141
"exports": {
4242
".": {
43-
"types": "./dist/index.d.ts"
43+
"types": "./dist/index.d.mts"
4444
},
4545
"./package.json": "./package.json"
4646
},
4747
"scripts": {
48-
"build": "tsc --build",
49-
"dev": "tsc --build --watch",
48+
"build": "tsdown",
49+
"dev": "tsdown --watch",
5050
"prepublishOnly": "pnpm build",
5151
"typecheck": "tsgo --noEmit"
5252
},

packages/spec-types/src/extensions/openapi.ts renamed to packages/spec-types/src/extensions/code-samples.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,3 @@ export interface CodeSampleObject {
4141
*/
4242
source: string;
4343
}
44-
45-
export interface EnumExtensions {
46-
/**
47-
* `x-enum-descriptions` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
48-
*/
49-
'x-enum-descriptions'?: ReadonlyArray<string>;
50-
/**
51-
* `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
52-
*/
53-
'x-enum-varnames'?: ReadonlyArray<string>;
54-
/**
55-
* {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names.
56-
*/
57-
'x-enumNames'?: ReadonlyArray<string>;
58-
}
59-
60-
/**
61-
* OpenAPI Specification Extensions.
62-
*
63-
* See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}.
64-
*/
65-
export interface OpenAPIExtensions {
66-
[extension: `x-${string}`]: unknown;
67-
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export interface EnumExtensions {
2+
/**
3+
* `x-enum-descriptions` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
4+
*/
5+
'x-enum-descriptions'?: Array<string>;
6+
/**
7+
* `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
8+
*/
9+
'x-enum-varnames'?: Array<string>;
10+
/**
11+
* {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names.
12+
*/
13+
'x-enumNames'?: Array<string>;
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Specification Extensions.
3+
*
4+
* See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}.
5+
*/
6+
export interface SpecExtensions {
7+
[extension: `x-${string}`]: unknown;
8+
}

packages/spec-types/src/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
export type {
2-
CodeSampleObject,
3-
EnumExtensions,
4-
LinguistLanguages,
5-
OpenAPIExtensions,
6-
} from './extensions/openapi';
1+
export type { CodeSampleObject, LinguistLanguages } from './extensions/code-samples';
2+
export type { EnumExtensions } from './extensions/enum';
3+
export type { SpecExtensions } from './extensions/spec';
74
export type * as JSONSchemaDraft4 from './json-schema/draft-4';
85
export type * as JSONSchemaDraft2020_12 from './json-schema/draft-2020-12';
96
export * as JSONSchema from './json-schema/union';

0 commit comments

Comments
 (0)