Skip to content

Commit e42b47b

Browse files
committed
chore: switch to openapi3-ts which requires no patches
1 parent 0485791 commit e42b47b

16 files changed

Lines changed: 50 additions & 105 deletions

lib/api.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Construct, type IConstruct } from 'constructs';
21
import type { JSONSchema7 } from 'json-schema';
3-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
43
import { ApiLowLevel } from './ApiLowLevel.js';
54
import { Parameter } from './parameter.js';
65
import { Path } from './path.js';
@@ -17,7 +16,7 @@ export enum OpenApiVersion {
1716

1817
export interface ApiOptions {
1918
openapi: OpenApiVersion; // | `${OpenApiVersion}`;
20-
info: OpenAPIV3_1.InfoObject;
19+
info: oas31.InfoObject;
2120
}
2221

2322
export class Api extends ApiLowLevel {
@@ -68,7 +67,7 @@ export class Api extends ApiLowLevel {
6867
child instanceof SecurityRequirement,
6968
)
7069
.map((child) => child.synth()),
71-
} satisfies OpenAPIV3_1.Document;
70+
} satisfies oas31.OpenAPIObject;
7271
}
7372

7473
public synthJsonSchema() {

lib/media-type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import { Reference } from './reference.js';
44
import type { Schema } from './schema.js';
55

@@ -24,7 +24,7 @@ export class MediaType extends Construct {
2424
this.options = options;
2525
}
2626

27-
public synth(): OpenAPIV3_1.MediaTypeObject {
27+
public synth(): oas31.MediaTypeObject {
2828
return {
2929
schema:
3030
this.options.schema instanceof Reference

lib/operation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import type { HttpMethods } from './http-methods.js';
44
import type { Parameter } from './parameter.js';
55
import { RequestBody, type RequestBodyOptions } from './request-body.js';
@@ -92,6 +92,6 @@ export class Operation<TPath extends string = '/'> extends Construct {
9292
]),
9393
),
9494
}),
95-
} satisfies OpenAPIV3_1.OperationObject;
95+
} satisfies oas31.OperationObject;
9696
}
9797
}

lib/parameter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import type { Api } from './api.js';
44
import type { Schema } from './schema.js';
55

@@ -34,7 +34,7 @@ export class Parameter<
3434
this.options = options;
3535
}
3636

37-
public referenceObject(): OpenAPIV3_1.ReferenceObject {
37+
public referenceObject(): oas31.ReferenceObject {
3838
return {
3939
$ref: this.jsonPointer(),
4040
};
@@ -66,6 +66,6 @@ export class Parameter<
6666
...(this.options.schema && {
6767
schema: this.options.schema.referenceObject(),
6868
}),
69-
} satisfies OpenAPIV3_1.ParameterObject | OpenAPIV3_1.ReferenceObject;
69+
} satisfies oas31.ParameterObject | oas31.ReferenceObject;
7070
}
7171
}

lib/path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { strict } from 'node:assert';
22
import { Construct } from 'constructs';
3-
import type { OpenAPIV3_1 } from 'openapi-types';
3+
import type { oas31 } from 'openapi3-ts';
44
import type { Api } from './api.js';
55
import { HttpMethods } from './http-methods.js';
66
import { Operation, type OperationOptions } from './operation.js';
@@ -63,6 +63,6 @@ export class Path<TPath extends string = '/'> extends Construct {
6363
),
6464
}),
6565
...(this.options.summary && { summary: this.options.summary }),
66-
} satisfies OpenAPIV3_1.PathItemObject;
66+
} satisfies oas31.PathItemObject;
6767
}
6868
}

lib/reference.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import { ApiLowLevel } from './ApiLowLevel.js';
44
import { Schema } from './schema.js';
55

@@ -22,7 +22,7 @@ export class Reference<T extends Target> extends Construct {
2222
return this.schema.schemaKey;
2323
}
2424

25-
public synth(): OpenAPIV3_1.ReferenceObject {
25+
public synth(): oas31.ReferenceObject {
2626
return this.schema.referenceObject();
2727
}
2828
}

lib/request-body.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import { MediaType, type MediaTypeOptions } from './media-type.js';
44

55
export interface RequestBodyOptions {
@@ -23,7 +23,7 @@ export class RequestBody extends Construct {
2323
: new MediaType(this, id, options.content);
2424
}
2525

26-
public synth(): OpenAPIV3_1.RequestBodyObject {
26+
public synth(): oas31.RequestBodyObject {
2727
return {
2828
description: this.options.description || '',
2929
content: {

lib/response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import type { Header } from './header.js';
44
import { MediaType, type MediaTypeOptions } from './media-type.js';
55

@@ -34,6 +34,6 @@ export class Response extends Construct {
3434
[this.content.contentType]: this.content.synth(),
3535
}),
3636
},
37-
} satisfies OpenAPIV3_1.ResponseObject;
37+
} satisfies oas31.ResponseObject;
3838
}
3939
}

lib/schema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33

4-
interface SchemaOptions<T extends OpenAPIV3_1.SchemaObject> {
4+
interface SchemaOptions<T extends oas31.SchemaObject> {
55
schema: T;
66
}
77

88
export class Schema<
9-
T extends OpenAPIV3_1.SchemaObject = OpenAPIV3_1.SchemaObject,
9+
T extends oas31.SchemaObject = oas31.SchemaObject,
1010
> extends Construct {
1111
private options: SchemaOptions<T>;
1212

@@ -28,10 +28,10 @@ export class Schema<
2828
return `#/components/schemas/${this.schemaKey}`;
2929
}
3030

31-
public referenceObject() {
31+
public referenceObject(): oas31.ReferenceObject {
3232
return {
3333
$ref: this.jsonPointer(),
34-
} satisfies OpenAPIV3_1.ReferenceObject;
34+
};
3535
}
3636

3737
// eslint-disable-next-line class-methods-use-this

lib/security-requirement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import type { OpenAPIV3_1 } from 'openapi-types';
2+
import type { oas31 } from 'openapi3-ts';
33
import type { Api } from './api.js';
44
import type { SecurityScheme } from './security-scheme.js';
55

@@ -20,7 +20,7 @@ export class SecurityRequirement extends Construct {
2020
this.options = options;
2121
}
2222

23-
public synth(): OpenAPIV3_1.SecurityRequirementObject {
23+
public synth(): oas31.SecurityRequirementObject {
2424
return this.options.securityScheme
2525
? {
2626
[this.options.securityScheme.node.id]: this.options.scopes || [],

0 commit comments

Comments
 (0)