Skip to content

Commit 12fa7d6

Browse files
committed
refactor: clean up folder structure
1 parent d129d2b commit 12fa7d6

9 files changed

Lines changed: 94 additions & 102 deletions

File tree

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'?: Array<string>;
50-
/**
51-
* `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
52-
*/
53-
'x-enum-varnames'?: Array<string>;
54-
/**
55-
* {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names.
56-
*/
57-
'x-enumNames'?: Array<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';

packages/spec-types/src/json-schema/draft-2020-12/spec.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
import type { AnyString, MaybeArray } from '@hey-api/types';
22

3-
import type { EnumExtensions, OpenAPIExtensions } from '../../extensions/openapi';
4-
import type { OpenAPIV3_1SchemaExtensions } from '../../openapi/v3-1/extensions';
5-
63
// TODO: left out some keywords related to structuring a complex schema and declaring a dialect
7-
export interface Document
8-
extends
9-
ArrayKeywords,
10-
NumberKeywords,
11-
ObjectKeywords,
12-
StringKeywords,
13-
EnumExtensions,
14-
OpenAPIV3_1SchemaExtensions,
15-
OpenAPIExtensions {
4+
export interface Document extends ArrayKeywords, NumberKeywords, ObjectKeywords, StringKeywords {
165
/**
176
* The `$comment` {@link https://json-schema.org/learn/glossary#keyword keyword} is strictly intended for adding comments to a schema. Its value must always be a string. Unlike the annotations `title`, `description`, and `examples`, JSON schema {@link https://json-schema.org/learn/glossary#implementation implementations} aren't allowed to attach any meaning or behavior to it whatsoever, and may even strip them at any time. Therefore, they are useful for leaving notes to future editors of a JSON schema, but should not be used to communicate to users of the schema.
187
*/

packages/spec-types/src/json-schema/draft-4/spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { AnyString } from '@hey-api/types';
22

3-
import type { EnumExtensions } from '../../extensions/openapi';
4-
5-
export interface Document extends EnumExtensions {
3+
export interface Document {
64
/**
75
* A schema can reference another schema using the `$ref` keyword. The value of `$ref` is a URI-reference that is resolved against the schema's {@link https://json-schema.org/understanding-json-schema/structuring#base-uri Base URI}. When evaluating a `$ref`, an implementation uses the resolved identifier to retrieve the referenced schema and applies that schema to the {@link https://json-schema.org/learn/glossary#instance instance}.
86
*

packages/spec-types/src/openapi/v2/spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { CodeSampleObject, EnumExtensions } from '../../extensions/openapi';
1+
import type { CodeSampleObject } from '../../extensions/code-samples';
2+
import type { EnumExtensions } from '../../extensions/enum';
23
import type { Document as JSONSchemaDraft4 } from '../../json-schema/draft-4/spec';
34
import type { OpenAPIV2NullableExtensions } from './extensions';
45

@@ -1306,7 +1307,8 @@ export interface ResponsesObject {
13061307
* - packSize
13071308
* ```
13081309
*/
1309-
export interface SchemaObject extends JSONSchemaDraft4, OpenAPIV2NullableExtensions {
1310+
export interface SchemaObject
1311+
extends JSONSchemaDraft4, EnumExtensions, OpenAPIV2NullableExtensions {
13101312
/**
13111313
* Allows extensions to the Swagger Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#specification-extensions Vendor Extensions} for further details.
13121314
*/

0 commit comments

Comments
 (0)