@scalar/workspace-store 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/client.d.ts +57 -30900
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -23
- package/dist/client.js.map +2 -2
- package/dist/navigation/helpers/get-tag.d.ts +13 -0
- package/dist/navigation/helpers/get-tag.d.ts.map +1 -0
- package/dist/navigation/helpers/get-tag.js +10 -0
- package/dist/navigation/helpers/get-tag.js.map +7 -0
- package/dist/navigation/helpers/traverse-description.d.ts +19 -0
- package/dist/navigation/helpers/traverse-description.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-description.js +50 -0
- package/dist/navigation/helpers/traverse-description.js.map +7 -0
- package/dist/navigation/helpers/traverse-document.d.ts +16 -0
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-document.js +53 -0
- package/dist/navigation/helpers/traverse-document.js.map +7 -0
- package/dist/navigation/helpers/traverse-paths.d.ts +21 -0
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-paths.js +39 -0
- package/dist/navigation/helpers/traverse-paths.js.map +7 -0
- package/dist/navigation/helpers/traverse-schemas.d.ts +16 -0
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-schemas.js +35 -0
- package/dist/navigation/helpers/traverse-schemas.js.map +7 -0
- package/dist/navigation/helpers/traverse-tags.d.ts +15 -0
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-tags.js +77 -0
- package/dist/navigation/helpers/traverse-tags.js.map +7 -0
- package/dist/navigation/helpers/traverse-webhooks.d.ts +19 -0
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -0
- package/dist/navigation/helpers/traverse-webhooks.js +40 -0
- package/dist/navigation/helpers/traverse-webhooks.js.map +7 -0
- package/dist/navigation/helpers/utils.d.ts +39 -0
- package/dist/navigation/helpers/utils.d.ts.map +1 -0
- package/dist/navigation/helpers/utils.js +25 -0
- package/dist/navigation/helpers/utils.js.map +7 -0
- package/dist/navigation/index.d.ts +3 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +5 -0
- package/dist/navigation/index.js.map +7 -0
- package/dist/navigation/types.d.ts +94 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -0
- package/dist/navigation/types.js.map +7 -0
- package/dist/schemas/extensions.d.ts +14 -0
- package/dist/schemas/extensions.d.ts.map +1 -0
- package/dist/schemas/extensions.js +17 -0
- package/dist/schemas/extensions.js.map +7 -0
- package/dist/schemas/{callback.d.ts.map → openapi-v3/callback.d.ts.map} +1 -1
- package/dist/schemas/{callback.js.map → openapi-v3/callback.js.map} +1 -1
- package/dist/schemas/{components.d.ts.map → openapi-v3/components.d.ts.map} +1 -1
- package/dist/schemas/{components.js.map → openapi-v3/components.js.map} +1 -1
- package/dist/schemas/openapi-v3/contact.d.ts.map +1 -0
- package/dist/schemas/{contact.js.map → openapi-v3/contact.js.map} +1 -1
- package/dist/schemas/openapi-v3/discriminator.d.ts.map +1 -0
- package/dist/schemas/{discriminator.js.map → openapi-v3/discriminator.js.map} +1 -1
- package/dist/schemas/openapi-v3/encoding.d.ts.map +1 -0
- package/dist/schemas/{encoding.js.map → openapi-v3/encoding.js.map} +1 -1
- package/dist/schemas/openapi-v3/example.d.ts.map +1 -0
- package/dist/schemas/{example.js.map → openapi-v3/example.js.map} +1 -1
- package/dist/schemas/openapi-v3/external-documentation.d.ts.map +1 -0
- package/dist/schemas/{external-documentation.js.map → openapi-v3/external-documentation.js.map} +1 -1
- package/dist/schemas/openapi-v3/header.d.ts.map +1 -0
- package/dist/schemas/{header.js.map → openapi-v3/header.js.map} +1 -1
- package/dist/schemas/openapi-v3/info.d.ts.map +1 -0
- package/dist/schemas/{info.js.map → openapi-v3/info.js.map} +1 -1
- package/dist/schemas/openapi-v3/license.d.ts.map +1 -0
- package/dist/schemas/{license.js.map → openapi-v3/license.js.map} +1 -1
- package/dist/schemas/openapi-v3/link.d.ts.map +1 -0
- package/dist/schemas/{link.js.map → openapi-v3/link.js.map} +1 -1
- package/dist/schemas/openapi-v3/media-type.d.ts.map +1 -0
- package/dist/schemas/{media-type.js.map → openapi-v3/media-type.js.map} +1 -1
- package/dist/schemas/openapi-v3/oauth-flow.d.ts.map +1 -0
- package/dist/schemas/{oauth-flow.js.map → openapi-v3/oauth-flow.js.map} +1 -1
- package/dist/schemas/openapi-v3/oauthflows.d.ts.map +1 -0
- package/dist/schemas/{oauthflows.js.map → openapi-v3/oauthflows.js.map} +1 -1
- package/dist/schemas/{openapi-document.d.ts.map → openapi-v3/openapi-document.d.ts.map} +1 -1
- package/dist/schemas/{openapi-document.js.map → openapi-v3/openapi-document.js.map} +1 -1
- package/dist/schemas/openapi-v3/operation-without-callback.d.ts.map +1 -0
- package/dist/schemas/{operation-without-callback.js.map → openapi-v3/operation-without-callback.js.map} +1 -1
- package/dist/schemas/openapi-v3/parameter.d.ts.map +1 -0
- package/dist/schemas/{parameter.js.map → openapi-v3/parameter.js.map} +1 -1
- package/dist/schemas/{path-item.d.ts.map → openapi-v3/path-item.d.ts.map} +1 -1
- package/dist/schemas/{path-item.js.map → openapi-v3/path-item.js.map} +1 -1
- package/dist/schemas/{paths.d.ts.map → openapi-v3/paths.d.ts.map} +1 -1
- package/dist/schemas/{paths.js.map → openapi-v3/paths.js.map} +1 -1
- package/dist/schemas/openapi-v3/reference.d.ts.map +1 -0
- package/dist/schemas/{reference.js.map → openapi-v3/reference.js.map} +1 -1
- package/dist/schemas/openapi-v3/request-body.d.ts.map +1 -0
- package/dist/schemas/{request-body.js.map → openapi-v3/request-body.js.map} +1 -1
- package/dist/schemas/openapi-v3/response.d.ts.map +1 -0
- package/dist/schemas/{response.js.map → openapi-v3/response.js.map} +1 -1
- package/dist/schemas/openapi-v3/responses.d.ts.map +1 -0
- package/dist/schemas/{responses.js.map → openapi-v3/responses.js.map} +1 -1
- package/dist/schemas/openapi-v3/schema.d.ts.map +1 -0
- package/dist/schemas/{schema.js.map → openapi-v3/schema.js.map} +1 -1
- package/dist/schemas/openapi-v3/security-requirement.d.ts.map +1 -0
- package/dist/schemas/{security-requirement.js.map → openapi-v3/security-requirement.js.map} +1 -1
- package/dist/schemas/openapi-v3/security-scheme.d.ts.map +1 -0
- package/dist/schemas/{security-scheme.js.map → openapi-v3/security-scheme.js.map} +1 -1
- package/dist/schemas/openapi-v3/server-variable.d.ts.map +1 -0
- package/dist/schemas/{server-variable.js.map → openapi-v3/server-variable.js.map} +1 -1
- package/dist/schemas/openapi-v3/server.d.ts.map +1 -0
- package/dist/schemas/{server.js.map → openapi-v3/server.js.map} +1 -1
- package/dist/schemas/openapi-v3/tag.d.ts.map +1 -0
- package/dist/schemas/{tag.js.map → openapi-v3/tag.js.map} +1 -1
- package/dist/schemas/openapi-v3/xml.d.ts.map +1 -0
- package/dist/schemas/{xml.js.map → openapi-v3/xml.js.map} +1 -1
- package/dist/schemas/{server-workspace.d.ts → workspace.d.ts} +20 -19
- package/dist/schemas/{server-workspace.d.ts.map → workspace.d.ts.map} +1 -1
- package/dist/schemas/workspace.js +31 -0
- package/dist/schemas/workspace.js.map +7 -0
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/server.d.ts +14 -16
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12 -2
- package/dist/server.js.map +2 -2
- package/package.json +11 -4
- package/.turbo/turbo-build.log +0 -13
- package/dist/schemas/contact.d.ts.map +0 -1
- package/dist/schemas/discriminator.d.ts.map +0 -1
- package/dist/schemas/encoding.d.ts.map +0 -1
- package/dist/schemas/example.d.ts.map +0 -1
- package/dist/schemas/external-documentation.d.ts.map +0 -1
- package/dist/schemas/header.d.ts.map +0 -1
- package/dist/schemas/info.d.ts.map +0 -1
- package/dist/schemas/license.d.ts.map +0 -1
- package/dist/schemas/link.d.ts.map +0 -1
- package/dist/schemas/media-type.d.ts.map +0 -1
- package/dist/schemas/oauth-flow.d.ts.map +0 -1
- package/dist/schemas/oauthflows.d.ts.map +0 -1
- package/dist/schemas/operation-without-callback.d.ts.map +0 -1
- package/dist/schemas/parameter.d.ts.map +0 -1
- package/dist/schemas/reference.d.ts.map +0 -1
- package/dist/schemas/request-body.d.ts.map +0 -1
- package/dist/schemas/response.d.ts.map +0 -1
- package/dist/schemas/responses.d.ts.map +0 -1
- package/dist/schemas/schema.d.ts.map +0 -1
- package/dist/schemas/security-requirement.d.ts.map +0 -1
- package/dist/schemas/security-scheme.d.ts.map +0 -1
- package/dist/schemas/server-variable.d.ts.map +0 -1
- package/dist/schemas/server-workspace.js +0 -29
- package/dist/schemas/server-workspace.js.map +0 -7
- package/dist/schemas/server.d.ts.map +0 -1
- package/dist/schemas/tag.d.ts.map +0 -1
- package/dist/schemas/xml.d.ts.map +0 -1
- package/esbuild.ts +0 -8
- package/src/client.test.ts +0 -409
- package/src/client.ts +0 -254
- package/src/helpers/general.ts +0 -30
- package/src/helpers/json-path-utils.test.ts +0 -13
- package/src/helpers/json-path-utils.ts +0 -38
- package/src/helpers/proxy.test.ts +0 -61
- package/src/helpers/proxy.ts +0 -213
- package/src/schemas/callback.ts +0 -13
- package/src/schemas/components.ts +0 -36
- package/src/schemas/contact.ts +0 -11
- package/src/schemas/discriminator.ts +0 -13
- package/src/schemas/encoding.ts +0 -17
- package/src/schemas/example.ts +0 -17
- package/src/schemas/external-documentation.ts +0 -9
- package/src/schemas/header.ts +0 -19
- package/src/schemas/info.ts +0 -23
- package/src/schemas/license.ts +0 -11
- package/src/schemas/link.ts +0 -24
- package/src/schemas/media-type.ts +0 -21
- package/src/schemas/oauth-flow.ts +0 -13
- package/src/schemas/oauthflows.ts +0 -16
- package/src/schemas/openapi-document.ts +0 -34
- package/src/schemas/operation-without-callback.ts +0 -37
- package/src/schemas/parameter.ts +0 -26
- package/src/schemas/path-item.ts +0 -35
- package/src/schemas/paths.ts +0 -11
- package/src/schemas/reference.ts +0 -20
- package/src/schemas/request-body.ts +0 -12
- package/src/schemas/response.ts +0 -16
- package/src/schemas/responses.ts +0 -14
- package/src/schemas/schema.ts +0 -26
- package/src/schemas/security-requirement.ts +0 -16
- package/src/schemas/security-scheme.ts +0 -58
- package/src/schemas/server-variable.ts +0 -11
- package/src/schemas/server-workspace.ts +0 -36
- package/src/schemas/server.ts +0 -12
- package/src/schemas/tag.ts +0 -12
- package/src/schemas/xml.ts +0 -19
- package/src/schemas.ts +0 -6
- package/src/server.test.ts +0 -470
- package/src/server.ts +0 -341
- package/test/helpers.ts +0 -16
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -8
- package/vite.config.ts +0 -9
- /package/dist/schemas/{callback.d.ts → openapi-v3/callback.d.ts} +0 -0
- /package/dist/schemas/{callback.js → openapi-v3/callback.js} +0 -0
- /package/dist/schemas/{components.d.ts → openapi-v3/components.d.ts} +0 -0
- /package/dist/schemas/{components.js → openapi-v3/components.js} +0 -0
- /package/dist/schemas/{contact.d.ts → openapi-v3/contact.d.ts} +0 -0
- /package/dist/schemas/{contact.js → openapi-v3/contact.js} +0 -0
- /package/dist/schemas/{discriminator.d.ts → openapi-v3/discriminator.d.ts} +0 -0
- /package/dist/schemas/{discriminator.js → openapi-v3/discriminator.js} +0 -0
- /package/dist/schemas/{encoding.d.ts → openapi-v3/encoding.d.ts} +0 -0
- /package/dist/schemas/{encoding.js → openapi-v3/encoding.js} +0 -0
- /package/dist/schemas/{example.d.ts → openapi-v3/example.d.ts} +0 -0
- /package/dist/schemas/{example.js → openapi-v3/example.js} +0 -0
- /package/dist/schemas/{external-documentation.d.ts → openapi-v3/external-documentation.d.ts} +0 -0
- /package/dist/schemas/{external-documentation.js → openapi-v3/external-documentation.js} +0 -0
- /package/dist/schemas/{header.d.ts → openapi-v3/header.d.ts} +0 -0
- /package/dist/schemas/{header.js → openapi-v3/header.js} +0 -0
- /package/dist/schemas/{info.d.ts → openapi-v3/info.d.ts} +0 -0
- /package/dist/schemas/{info.js → openapi-v3/info.js} +0 -0
- /package/dist/schemas/{license.d.ts → openapi-v3/license.d.ts} +0 -0
- /package/dist/schemas/{license.js → openapi-v3/license.js} +0 -0
- /package/dist/schemas/{link.d.ts → openapi-v3/link.d.ts} +0 -0
- /package/dist/schemas/{link.js → openapi-v3/link.js} +0 -0
- /package/dist/schemas/{media-type.d.ts → openapi-v3/media-type.d.ts} +0 -0
- /package/dist/schemas/{media-type.js → openapi-v3/media-type.js} +0 -0
- /package/dist/schemas/{oauth-flow.d.ts → openapi-v3/oauth-flow.d.ts} +0 -0
- /package/dist/schemas/{oauth-flow.js → openapi-v3/oauth-flow.js} +0 -0
- /package/dist/schemas/{oauthflows.d.ts → openapi-v3/oauthflows.d.ts} +0 -0
- /package/dist/schemas/{oauthflows.js → openapi-v3/oauthflows.js} +0 -0
- /package/dist/schemas/{openapi-document.d.ts → openapi-v3/openapi-document.d.ts} +0 -0
- /package/dist/schemas/{openapi-document.js → openapi-v3/openapi-document.js} +0 -0
- /package/dist/schemas/{operation-without-callback.d.ts → openapi-v3/operation-without-callback.d.ts} +0 -0
- /package/dist/schemas/{operation-without-callback.js → openapi-v3/operation-without-callback.js} +0 -0
- /package/dist/schemas/{parameter.d.ts → openapi-v3/parameter.d.ts} +0 -0
- /package/dist/schemas/{parameter.js → openapi-v3/parameter.js} +0 -0
- /package/dist/schemas/{path-item.d.ts → openapi-v3/path-item.d.ts} +0 -0
- /package/dist/schemas/{path-item.js → openapi-v3/path-item.js} +0 -0
- /package/dist/schemas/{paths.d.ts → openapi-v3/paths.d.ts} +0 -0
- /package/dist/schemas/{paths.js → openapi-v3/paths.js} +0 -0
- /package/dist/schemas/{reference.d.ts → openapi-v3/reference.d.ts} +0 -0
- /package/dist/schemas/{reference.js → openapi-v3/reference.js} +0 -0
- /package/dist/schemas/{request-body.d.ts → openapi-v3/request-body.d.ts} +0 -0
- /package/dist/schemas/{request-body.js → openapi-v3/request-body.js} +0 -0
- /package/dist/schemas/{response.d.ts → openapi-v3/response.d.ts} +0 -0
- /package/dist/schemas/{response.js → openapi-v3/response.js} +0 -0
- /package/dist/schemas/{responses.d.ts → openapi-v3/responses.d.ts} +0 -0
- /package/dist/schemas/{responses.js → openapi-v3/responses.js} +0 -0
- /package/dist/schemas/{schema.d.ts → openapi-v3/schema.d.ts} +0 -0
- /package/dist/schemas/{schema.js → openapi-v3/schema.js} +0 -0
- /package/dist/schemas/{security-requirement.d.ts → openapi-v3/security-requirement.d.ts} +0 -0
- /package/dist/schemas/{security-requirement.js → openapi-v3/security-requirement.js} +0 -0
- /package/dist/schemas/{security-scheme.d.ts → openapi-v3/security-scheme.d.ts} +0 -0
- /package/dist/schemas/{security-scheme.js → openapi-v3/security-scheme.js} +0 -0
- /package/dist/schemas/{server-variable.d.ts → openapi-v3/server-variable.d.ts} +0 -0
- /package/dist/schemas/{server-variable.js → openapi-v3/server-variable.js} +0 -0
- /package/dist/schemas/{server.d.ts → openapi-v3/server.d.ts} +0 -0
- /package/dist/schemas/{server.js → openapi-v3/server.js} +0 -0
- /package/dist/schemas/{tag.d.ts → openapi-v3/tag.d.ts} +0 -0
- /package/dist/schemas/{tag.js → openapi-v3/tag.js} +0 -0
- /package/dist/schemas/{xml.d.ts → openapi-v3/xml.d.ts} +0 -0
- /package/dist/schemas/{xml.js → openapi-v3/xml.js} +0 -0
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a JSON Pointer string into an array of path segments
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* parseJsonPointer('#/components/schemas/User')
|
|
7
|
-
*
|
|
8
|
-
* ['components', 'schemas', 'User']
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export function parseJsonPointer(pointer: string): string[] {
|
|
12
|
-
return (
|
|
13
|
-
pointer
|
|
14
|
-
// Split on '/'
|
|
15
|
-
.split('/')
|
|
16
|
-
// Remove the leading '#' if present
|
|
17
|
-
.filter((segment, index) => (index !== 0 || segment !== '#') && segment)
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves a nested value from the source document using a path array
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* getValueByPath(document, ['components', 'schemas', 'User'])
|
|
27
|
-
*
|
|
28
|
-
* { id: '123', name: 'John Doe' }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function getValueByPath(obj: any, pointer: string[]): unknown {
|
|
32
|
-
return pointer.reduce((acc, part) => {
|
|
33
|
-
if (acc === undefined || acc === null) {
|
|
34
|
-
return undefined
|
|
35
|
-
}
|
|
36
|
-
return acc[part]
|
|
37
|
-
}, obj)
|
|
38
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createMagicProxy } from '@/helpers/proxy'
|
|
2
|
-
import { describe, expect, test } from 'vitest'
|
|
3
|
-
|
|
4
|
-
describe('createMagicProxy', () => {
|
|
5
|
-
test('should correctly proxy internal refs', () => {
|
|
6
|
-
const input = {
|
|
7
|
-
a: 'hello',
|
|
8
|
-
b: {
|
|
9
|
-
'$ref': '#/a',
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const result = createMagicProxy(input)
|
|
14
|
-
|
|
15
|
-
expect(result.b).toBe('hello')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('should correctly proxy deep nested refs', () => {
|
|
19
|
-
const input = {
|
|
20
|
-
a: {
|
|
21
|
-
b: {
|
|
22
|
-
c: {
|
|
23
|
-
d: {
|
|
24
|
-
prop: 'hello',
|
|
25
|
-
},
|
|
26
|
-
e: {
|
|
27
|
-
'$ref': '#/a/b/c/d',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const result = createMagicProxy(input) as any
|
|
35
|
-
expect(result.a.b.c.e.prop).toBe('hello')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('should correctly proxy multi refs', () => {
|
|
39
|
-
const input = {
|
|
40
|
-
a: {
|
|
41
|
-
b: {
|
|
42
|
-
c: {
|
|
43
|
-
prop: 'hello',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
e: {
|
|
48
|
-
f: {
|
|
49
|
-
$ref: '#/a/b/c/prop',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
d: {
|
|
53
|
-
$ref: '#/e/f',
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const result = createMagicProxy(input)
|
|
58
|
-
|
|
59
|
-
expect(result.d).toBe('hello')
|
|
60
|
-
})
|
|
61
|
-
})
|
package/src/helpers/proxy.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { isReactive, toRaw } from 'vue'
|
|
2
|
-
import { getValueByPath, parseJsonPointer } from './json-path-utils'
|
|
3
|
-
import { isLocalRef, isObject } from './general'
|
|
4
|
-
import type { UnknownObject } from './general'
|
|
5
|
-
|
|
6
|
-
export const TARGET_SYMBOL = Symbol('target')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a proxy handler that automatically resolves JSON references ($ref) in an object.
|
|
10
|
-
* The handler intercepts property access, assignment, and property enumeration to automatically
|
|
11
|
-
* resolve any $ref references to their target values in the source document.
|
|
12
|
-
*
|
|
13
|
-
* @param sourceDocument - The source document containing the reference targets
|
|
14
|
-
* @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies
|
|
15
|
-
* @returns A proxy handler that automatically resolves $ref references
|
|
16
|
-
*/
|
|
17
|
-
function createProxyHandler(
|
|
18
|
-
sourceDocument: UnknownObject,
|
|
19
|
-
resolvedProxyCache?: WeakMap<object, UnknownObject>,
|
|
20
|
-
): ProxyHandler<UnknownObject> {
|
|
21
|
-
return {
|
|
22
|
-
get(target, property, receiver) {
|
|
23
|
-
if (property === TARGET_SYMBOL) {
|
|
24
|
-
return target
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (property === '__isProxy') {
|
|
28
|
-
return true
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const value = Reflect.get(target, property, receiver)
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Recursively resolves nested references in an object.
|
|
35
|
-
* If the value is not an object, returns it as is.
|
|
36
|
-
* If the value has a $ref property:
|
|
37
|
-
* - For local references: resolves the reference and continues resolving nested refs
|
|
38
|
-
* - For all other objects: creates a proxy for lazy resolution
|
|
39
|
-
*/
|
|
40
|
-
const deepResolveNestedRefs = (value: unknown) => {
|
|
41
|
-
if (!isObject(value)) {
|
|
42
|
-
return value
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if ('$ref' in value) {
|
|
46
|
-
const ref = value.$ref as string
|
|
47
|
-
|
|
48
|
-
if (isLocalRef(ref)) {
|
|
49
|
-
const referencePath = parseJsonPointer(ref)
|
|
50
|
-
const resolvedValue = getValueByPath(sourceDocument, referencePath)
|
|
51
|
-
|
|
52
|
-
return deepResolveNestedRefs(resolvedValue)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return createMagicProxy(value, sourceDocument, resolvedProxyCache)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return deepResolveNestedRefs(value)
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
set(target: UnknownObject, property: string, newValue: unknown, receiver: UnknownObject) {
|
|
63
|
-
const rawTarget = isReactive(target) ? toRaw(target) : target
|
|
64
|
-
const currentValue = rawTarget[property]
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
isObject(currentValue) &&
|
|
68
|
-
'$ref' in currentValue &&
|
|
69
|
-
typeof currentValue.$ref === 'string' &&
|
|
70
|
-
isLocalRef(currentValue.$ref)
|
|
71
|
-
) {
|
|
72
|
-
const referencePath = parseJsonPointer(currentValue.$ref)
|
|
73
|
-
const targetObject = getValueByPath(sourceDocument, referencePath.slice(0, -1)) as UnknownObject
|
|
74
|
-
const lastPathSegment = referencePath[referencePath.length - 1]
|
|
75
|
-
|
|
76
|
-
if (targetObject && lastPathSegment) {
|
|
77
|
-
targetObject[lastPathSegment] = newValue
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
Reflect.set(rawTarget, property, newValue, receiver)
|
|
81
|
-
}
|
|
82
|
-
return true
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
has(target: UnknownObject, key: string) {
|
|
86
|
-
if (typeof key === 'string' && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {
|
|
87
|
-
const referencePath = parseJsonPointer(target['$ref'])
|
|
88
|
-
const resolvedValue = getValueByPath(sourceDocument, referencePath) as UnknownObject
|
|
89
|
-
|
|
90
|
-
return resolvedValue ? key in resolvedValue : false
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return key in target
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
ownKeys(target: UnknownObject) {
|
|
97
|
-
if ('$ref' in target && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {
|
|
98
|
-
const referencePath = parseJsonPointer(target['$ref'])
|
|
99
|
-
const resolvedValue = getValueByPath(sourceDocument, referencePath)
|
|
100
|
-
|
|
101
|
-
return resolvedValue ? Reflect.ownKeys(resolvedValue) : []
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return Reflect.ownKeys(target)
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
getOwnPropertyDescriptor(target: UnknownObject, key: string) {
|
|
108
|
-
if ('$ref' in target && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {
|
|
109
|
-
const referencePath = parseJsonPointer(target['$ref'])
|
|
110
|
-
const resolvedValue = getValueByPath(sourceDocument, referencePath)
|
|
111
|
-
|
|
112
|
-
if (resolvedValue) {
|
|
113
|
-
return Object.getOwnPropertyDescriptor(resolvedValue, key)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return Object.getOwnPropertyDescriptor(target, key)
|
|
118
|
-
},
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Creates a proxy that automatically resolves JSON references ($ref) in an object.
|
|
124
|
-
* The proxy intercepts property access and automatically resolves any $ref references
|
|
125
|
-
* to their target values in the source document.
|
|
126
|
-
*
|
|
127
|
-
* @param targetObject - The object to create a proxy for
|
|
128
|
-
* @param sourceDocument - The source document containing the reference targets (defaults to targetObject)
|
|
129
|
-
* @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies
|
|
130
|
-
* @returns A proxy that automatically resolves $ref references
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* // Basic usage with local references
|
|
134
|
-
* const doc = {
|
|
135
|
-
* components: {
|
|
136
|
-
* schemas: {
|
|
137
|
-
* User: { type: 'object', properties: { name: { type: 'string' } } }
|
|
138
|
-
* }
|
|
139
|
-
* },
|
|
140
|
-
* paths: {
|
|
141
|
-
* '/users': {
|
|
142
|
-
* get: {
|
|
143
|
-
* responses: {
|
|
144
|
-
* 200: {
|
|
145
|
-
* content: {
|
|
146
|
-
* 'application/json': {
|
|
147
|
-
* schema: { $ref: '#/components/schemas/User' }
|
|
148
|
-
* }
|
|
149
|
-
* }
|
|
150
|
-
* }
|
|
151
|
-
* }
|
|
152
|
-
* }
|
|
153
|
-
* }
|
|
154
|
-
* }
|
|
155
|
-
* }
|
|
156
|
-
*
|
|
157
|
-
* const proxy = createMagicProxy(doc)
|
|
158
|
-
* // Accessing the schema will automatically resolve the $ref
|
|
159
|
-
* console.log(proxy.paths['/users'].get.responses[200].content['application/json'].schema)
|
|
160
|
-
* // Output: { type: 'object', properties: { name: { type: 'string' } } }
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* // Using with a cache to prevent duplicate proxies
|
|
164
|
-
* const cache = new WeakMap()
|
|
165
|
-
* const proxy1 = createMagicProxy(doc, doc, cache)
|
|
166
|
-
* const proxy2 = createMagicProxy(doc, doc, cache)
|
|
167
|
-
* // proxy1 and proxy2 are the same instance due to caching
|
|
168
|
-
* console.log(proxy1 === proxy2) // true
|
|
169
|
-
*/
|
|
170
|
-
export function createMagicProxy<T extends UnknownObject>(
|
|
171
|
-
targetObject: T,
|
|
172
|
-
sourceDocument: T = targetObject,
|
|
173
|
-
resolvedProxyCache?: WeakMap<object, T>,
|
|
174
|
-
): T {
|
|
175
|
-
if (!isObject(targetObject)) {
|
|
176
|
-
return targetObject
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const rawTarget = isReactive(targetObject) ? toRaw(targetObject) : targetObject
|
|
180
|
-
|
|
181
|
-
// check for cached results
|
|
182
|
-
if (resolvedProxyCache?.has(rawTarget)) {
|
|
183
|
-
const cachedValue = resolvedProxyCache.get(rawTarget)
|
|
184
|
-
|
|
185
|
-
if (cachedValue) {
|
|
186
|
-
return cachedValue
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Create a handler with the correct context
|
|
191
|
-
const handler = createProxyHandler(sourceDocument, resolvedProxyCache)
|
|
192
|
-
const proxy = new Proxy<T>(rawTarget, handler)
|
|
193
|
-
|
|
194
|
-
if (resolvedProxyCache) {
|
|
195
|
-
resolvedProxyCache.set(rawTarget, proxy)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return proxy
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Gets the raw (non-proxied) version of an object created by createMagicProxy.
|
|
203
|
-
* This is useful when you need to access the original object without the magic proxy wrapper.
|
|
204
|
-
*
|
|
205
|
-
* @param obj - The magic proxy object to get the raw version of
|
|
206
|
-
* @returns The raw version of the object
|
|
207
|
-
* @example
|
|
208
|
-
* const proxy = createMagicProxy({ foo: { $ref: '#/bar' } })
|
|
209
|
-
* const raw = getRaw(proxy) // { foo: { $ref: '#/bar' } }
|
|
210
|
-
*/
|
|
211
|
-
export function getRaw(obj: UnknownObject) {
|
|
212
|
-
return (obj as { [TARGET_SYMBOL]: UnknownObject })[TARGET_SYMBOL]
|
|
213
|
-
}
|
package/src/schemas/callback.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { PathItemObject } from './path-item'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the Path Item Object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.
|
|
6
|
-
*
|
|
7
|
-
* To describe incoming requests from the API provider independent from another API call, use the webhooks field.
|
|
8
|
-
*/
|
|
9
|
-
export const CallbackObject = Type.Record(
|
|
10
|
-
Type.String(),
|
|
11
|
-
/** A Path Item Object used to define a callback request and expected responses. A complete example is available. */
|
|
12
|
-
PathItemObject,
|
|
13
|
-
)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { SchemaObject } from './schema'
|
|
3
|
-
import { ResponseObject } from './response'
|
|
4
|
-
import { ReferenceObject } from './reference'
|
|
5
|
-
import { ParameterObject } from './parameter'
|
|
6
|
-
import { ExampleObject } from './example'
|
|
7
|
-
import { RequestBodyObject } from './request-body'
|
|
8
|
-
import { SecuritySchemeObject } from './security-scheme'
|
|
9
|
-
import { LinkObject } from './link'
|
|
10
|
-
import { CallbackObject } from './callback'
|
|
11
|
-
import { PathItemObject } from './path-item'
|
|
12
|
-
import { HeaderObject } from './header'
|
|
13
|
-
|
|
14
|
-
/** Holds a set of reusable objects for different aspects of the OAS. All objects defined within the Components Object will have no effect on the API unless they are explicitly referenced from outside the Components Object. */
|
|
15
|
-
export const ComponentsObject = Type.Object({
|
|
16
|
-
/** An object to hold reusable Schema Objects. */
|
|
17
|
-
schemas: Type.Optional(Type.Record(Type.String(), SchemaObject)),
|
|
18
|
-
/** An object to hold reusable Response Objects. */
|
|
19
|
-
responses: Type.Optional(Type.Record(Type.String(), Type.Union([ResponseObject, ReferenceObject]))),
|
|
20
|
-
/** An object to hold reusable Parameter Objects. */
|
|
21
|
-
parameters: Type.Optional(Type.Record(Type.String(), Type.Union([ParameterObject, ReferenceObject]))),
|
|
22
|
-
/** An object to hold reusable Example Objects. */
|
|
23
|
-
examples: Type.Optional(Type.Record(Type.String(), Type.Union([ExampleObject, ReferenceObject]))),
|
|
24
|
-
/** An object to hold reusable Request Body Objects. */
|
|
25
|
-
requestBodies: Type.Optional(Type.Record(Type.String(), Type.Union([RequestBodyObject, ReferenceObject]))),
|
|
26
|
-
/** An object to hold reusable Header Objects. */
|
|
27
|
-
headers: Type.Optional(Type.Record(Type.String(), Type.Union([HeaderObject, ReferenceObject]))),
|
|
28
|
-
/** An object to hold reusable Security Scheme Objects. */
|
|
29
|
-
securitySchemes: Type.Optional(Type.Record(Type.String(), Type.Union([SecuritySchemeObject, ReferenceObject]))),
|
|
30
|
-
/** An object to hold reusable Link Objects. */
|
|
31
|
-
links: Type.Optional(Type.Record(Type.String(), Type.Union([LinkObject, ReferenceObject]))),
|
|
32
|
-
/** An object to hold reusable Callback Objects. */
|
|
33
|
-
callbacks: Type.Optional(Type.Record(Type.String(), Type.Union([CallbackObject, ReferenceObject]))),
|
|
34
|
-
/** An object to hold reusable Path Item Objects. */
|
|
35
|
-
pathItems: Type.Optional(Type.Record(Type.String(), PathItemObject)),
|
|
36
|
-
})
|
package/src/schemas/contact.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/** Contact information for the exposed API. */
|
|
4
|
-
export const ContactObject = Type.Object({
|
|
5
|
-
/** The identifying name of the contact person/organization. */
|
|
6
|
-
name: Type.Optional(Type.String()),
|
|
7
|
-
/** The URI for the contact information. This MUST be in the form of a URI. */
|
|
8
|
-
url: Type.Optional(Type.String()),
|
|
9
|
-
/** The email address of the contact person/organization. This MUST be in the form of an email address. */
|
|
10
|
-
email: Type.Optional(Type.String()),
|
|
11
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* When request bodies or response payloads may be one of a number of different schemas, a Discriminator Object gives a hint about the expected schema of the document. This hint can be used to aid in serialization, deserialization, and validation. The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.
|
|
5
|
-
*
|
|
6
|
-
* Note that discriminator MUST NOT change the validation outcome of the schema.
|
|
7
|
-
*/
|
|
8
|
-
export const DiscriminatorObject = Type.Object({
|
|
9
|
-
/** REQUIRED. The name of the property in the payload that will hold the discriminating value. This property SHOULD be required in the payload schema, as the behavior when the property is absent is undefined. */
|
|
10
|
-
propertyName: Type.String(),
|
|
11
|
-
/** An object to hold mappings between payload values and schema names or URI references. */
|
|
12
|
-
mapping: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
13
|
-
})
|
package/src/schemas/encoding.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { HeaderObject } from './header'
|
|
3
|
-
import { ReferenceObject } from './reference'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A single encoding definition applied to a single schema property. See Appendix B for a discussion of converting values of various types to string representations.
|
|
7
|
-
*
|
|
8
|
-
* Properties are correlated with multipart parts using the name parameter of Content-Disposition: form-data, and with application/x-www-form-urlencoded using the query string parameter names. In both cases, their order is implementation-defined.
|
|
9
|
-
*
|
|
10
|
-
* See Appendix E for a detailed examination of percent-encoding concerns for form media types.
|
|
11
|
-
*/
|
|
12
|
-
export const EncodingObject = Type.Object({
|
|
13
|
-
/** The Content-Type for encoding a specific property. The value is a comma-separated list, each element of which is either a specific media type (e.g. image/png) or a wildcard media type (e.g. image/*). Default value depends on the property type as shown in the table below. */
|
|
14
|
-
contentType: Type.Optional(Type.String()),
|
|
15
|
-
/** A map allowing additional information to be provided as headers. Content-Type is described separately and SHALL be ignored in this section. This field SHALL be ignored if the request body media type is not a multipart. */
|
|
16
|
-
headers: Type.Optional(Type.Record(Type.String(), Type.Union([HeaderObject, ReferenceObject]))),
|
|
17
|
-
})
|
package/src/schemas/example.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* An object grouping an internal or external example value with basic summary and description metadata. This object is typically used in fields named examples (plural), and is a referenceable alternative to older example (singular) fields that do not support referencing or metadata.
|
|
5
|
-
*
|
|
6
|
-
* Examples allow demonstration of the usage of properties, parameters and objects within OpenAPI.
|
|
7
|
-
*/
|
|
8
|
-
export const ExampleObject = Type.Object({
|
|
9
|
-
/** Short description for the example. */
|
|
10
|
-
summary: Type.Optional(Type.String()),
|
|
11
|
-
/** Long description for the example. CommonMark syntax MAY be used for rich text representation. */
|
|
12
|
-
description: Type.Optional(Type.String()),
|
|
13
|
-
/** Embedded literal example. The value field and externalValue field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. */
|
|
14
|
-
value: Type.Optional(Type.Any()),
|
|
15
|
-
/** A URI that identifies the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The value field and externalValue field are mutually exclusive. See the rules for resolving Relative References. */
|
|
16
|
-
externalValue: Type.Optional(Type.String()),
|
|
17
|
-
})
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/** Allows referencing an external resource for extended documentation. */
|
|
4
|
-
export const ExternalDocumentationObject = Type.Object({
|
|
5
|
-
/** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
|
|
6
|
-
description: Type.Optional(Type.String()),
|
|
7
|
-
/** REQUIRED. The URI for the target documentation. This MUST be in the form of a URI. */
|
|
8
|
-
url: Type.String(),
|
|
9
|
-
})
|
package/src/schemas/header.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Describes a single header for HTTP responses and for individual parts in multipart representations; see the relevant Response Object and Encoding Object documentation for restrictions on which headers can be described.
|
|
5
|
-
*
|
|
6
|
-
* The Header Object follows the structure of the Parameter Object, including determining its serialization strategy based on whether schema or content is present, with the following changes:
|
|
7
|
-
*
|
|
8
|
-
* - name MUST NOT be specified, it is given in the corresponding headers map.
|
|
9
|
-
* - in MUST NOT be specified, it is implicitly in header.
|
|
10
|
-
* - All traits that are affected by the location MUST be applicable to a location of header (for example, style). This means that allowEmptyValue and allowReserved MUST NOT be used, and style, if used, MUST be limited to "simple".
|
|
11
|
-
*/
|
|
12
|
-
export const HeaderObject = Type.Object({
|
|
13
|
-
/** A brief description of the header. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
|
|
14
|
-
description: Type.Optional(Type.String()),
|
|
15
|
-
/** Determines whether this header is mandatory. The default value is false. */
|
|
16
|
-
required: Type.Optional(Type.Boolean()),
|
|
17
|
-
/** Specifies that the header is deprecated and SHOULD be transitioned out of usage. Default value is false. */
|
|
18
|
-
deprecated: Type.Optional(Type.Boolean()),
|
|
19
|
-
})
|
package/src/schemas/info.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { ContactObject } from './contact'
|
|
3
|
-
import { LicenseObject } from './license'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.
|
|
7
|
-
*/
|
|
8
|
-
export const InfoObject = Type.Object({
|
|
9
|
-
/** REQUIRED. The title of the API. */
|
|
10
|
-
title: Type.String({ default: 'API' }),
|
|
11
|
-
/** A short summary of the API. */
|
|
12
|
-
summary: Type.Optional(Type.String()),
|
|
13
|
-
/** A description of the API. CommonMark syntax MAY be used for rich text representation. */
|
|
14
|
-
description: Type.Optional(Type.String()),
|
|
15
|
-
/** A URI for the Terms of Service for the API. This MUST be in the form of a URI. */
|
|
16
|
-
termsOfService: Type.Optional(Type.String()),
|
|
17
|
-
/** The contact information for the exposed API. */
|
|
18
|
-
contact: Type.Optional(ContactObject),
|
|
19
|
-
/** The license information for the exposed API. */
|
|
20
|
-
license: Type.Optional(LicenseObject),
|
|
21
|
-
/** REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the version of the API being described or the version of the OpenAPI Description). */
|
|
22
|
-
version: Type.String(),
|
|
23
|
-
})
|
package/src/schemas/license.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/** The license information for the exposed API. */
|
|
4
|
-
export const LicenseObject = Type.Object({
|
|
5
|
-
/** REQUIRED. The license name used for the API. */
|
|
6
|
-
name: Type.Optional(Type.String()),
|
|
7
|
-
/** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
|
|
8
|
-
identifier: Type.Optional(Type.String()),
|
|
9
|
-
/** A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field. */
|
|
10
|
-
url: Type.Optional(Type.String()),
|
|
11
|
-
})
|
package/src/schemas/link.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { ServerObject } from './server'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The Link Object represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.
|
|
6
|
-
*
|
|
7
|
-
* Unlike dynamic links (i.e. links provided in the response payload), the OAS linking mechanism does not require link information in the runtime response.
|
|
8
|
-
*
|
|
9
|
-
* For computing links and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation.
|
|
10
|
-
*/
|
|
11
|
-
export const LinkObject = Type.Object({
|
|
12
|
-
/** A URI reference to an OAS operation. This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI Description. */
|
|
13
|
-
operationRef: Type.Optional(Type.String()),
|
|
14
|
-
/** The name of an existing, resolvable OAS operation, as defined with a unique operationId. This field is mutually exclusive of the operationRef field. */
|
|
15
|
-
operationId: Type.Optional(Type.String()),
|
|
16
|
-
/** A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. The key is the parameter name to be used (optionally qualified with the parameter location, e.g. path.id for an id parameter in the path), whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. */
|
|
17
|
-
parameters: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
18
|
-
/** A literal value or {expression} to use as a request body when calling the target operation. */
|
|
19
|
-
requestBody: Type.Optional(Type.Any()),
|
|
20
|
-
/** A description of the link. CommonMark syntax MAY be used for rich text representation. */
|
|
21
|
-
description: Type.Optional(Type.String()),
|
|
22
|
-
/** A server object to be used by the target operation. */
|
|
23
|
-
server: Type.Optional(ServerObject),
|
|
24
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { ExampleObject } from './example'
|
|
3
|
-
import { ReferenceObject } from './reference'
|
|
4
|
-
import { EncodingObject } from './encoding'
|
|
5
|
-
import { SchemaObject } from './schema'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Each Media Type Object provides schema and examples for the media type identified by its key.
|
|
9
|
-
*
|
|
10
|
-
* When example or examples are provided, the example SHOULD match the specified schema and be in the correct format as specified by the media type and its encoding. The example and examples fields are mutually exclusive, and if either is present it SHALL override any example in the schema. See Working With Examples for further guidance regarding the different ways of specifying examples, including non-JSON/YAML values.
|
|
11
|
-
*/
|
|
12
|
-
export const MediaTypeObject = Type.Object({
|
|
13
|
-
/** The schema defining the content of the request, response, parameter, or header. */
|
|
14
|
-
schema: Type.Optional(SchemaObject),
|
|
15
|
-
/** Example of the media type */
|
|
16
|
-
example: Type.Optional(Type.Any()),
|
|
17
|
-
/** Examples of the media type */
|
|
18
|
-
examples: Type.Optional(Type.Record(Type.String(), Type.Union([ExampleObject, ReferenceObject]))),
|
|
19
|
-
/** A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding field SHALL only apply to Request Body Objects, and only when the media type is multipart or application/x-www-form-urlencoded. If no Encoding Object is provided for a property, the behavior is determined by the default values documented for the Encoding Object. */
|
|
20
|
-
encoding: Type.Optional(Type.Record(Type.String(), EncodingObject)),
|
|
21
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
|
|
3
|
-
/** Configuration details for a supported OAuth Flow */
|
|
4
|
-
export const OAuthFlowObject = Type.Object({
|
|
5
|
-
/** REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
|
|
6
|
-
authorizationUrl: Type.String(),
|
|
7
|
-
/** REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
|
|
8
|
-
tokenUrl: Type.String(),
|
|
9
|
-
/** The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. */
|
|
10
|
-
refreshUrl: Type.Optional(Type.String()),
|
|
11
|
-
/** REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty. */
|
|
12
|
-
scopes: Type.Record(Type.String(), Type.String()),
|
|
13
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { OAuthFlowObject } from './oauth-flow'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Allows configuration of the supported OAuth Flows.
|
|
6
|
-
*/
|
|
7
|
-
export const OAuthFlowsObject = Type.Object({
|
|
8
|
-
/** Configuration for the OAuth Implicit flow */
|
|
9
|
-
implicit: Type.Optional(OAuthFlowObject),
|
|
10
|
-
/** Configuration for the OAuth Resource Owner Password flow */
|
|
11
|
-
password: Type.Optional(OAuthFlowObject),
|
|
12
|
-
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
|
|
13
|
-
clientCredentials: Type.Optional(OAuthFlowObject),
|
|
14
|
-
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0. */
|
|
15
|
-
authorizationCode: Type.Optional(OAuthFlowObject),
|
|
16
|
-
})
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Type, type Static } from '@sinclair/typebox'
|
|
2
|
-
import { InfoObject } from './info'
|
|
3
|
-
import { ServerObject } from './server'
|
|
4
|
-
import { PathsObject } from './paths'
|
|
5
|
-
import { PathItemObject } from './path-item'
|
|
6
|
-
import { ComponentsObject } from './components'
|
|
7
|
-
import { SecurityRequirementObject } from './security-requirement'
|
|
8
|
-
import { TagObject } from './tag'
|
|
9
|
-
import { ExternalDocumentationObject } from './external-documentation'
|
|
10
|
-
|
|
11
|
-
export const OpenAPIDocumentSchema = Type.Object({
|
|
12
|
-
/** REQUIRED. This string MUST be the version number of the OpenAPI Specification that the OpenAPI Document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI Document. This is not related to the API info.version string. */
|
|
13
|
-
openapi: Type.String(),
|
|
14
|
-
/** REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. */
|
|
15
|
-
info: InfoObject,
|
|
16
|
-
/** The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI. */
|
|
17
|
-
jsonSchemaDialect: Type.Optional(Type.String()),
|
|
18
|
-
/** An array of Server Objects, which provide connectivity information to a target server. If the servers field is not provided, or is an empty array, the default value would be a Server Object with a url value of /. */
|
|
19
|
-
servers: Type.Optional(Type.Array(ServerObject)),
|
|
20
|
-
/** The available paths and operations for the API. */
|
|
21
|
-
paths: Type.Optional(PathsObject),
|
|
22
|
-
/** The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the callbacks feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An example is available. */
|
|
23
|
-
webhooks: Type.Optional(Type.Record(Type.String(), PathItemObject)),
|
|
24
|
-
/** An element to hold various Objects for the OpenAPI Description. */
|
|
25
|
-
components: Type.Optional(ComponentsObject),
|
|
26
|
-
/** A declaration of which security mechanisms can be used across the API. The list of values includes alternative Security Requirement Objects that can be used. Only one of the Security Requirement Objects need to be satisfied to authorize a request. Individual operations can override this definition. The list can be incomplete, up to being empty or absent. To make security explicitly optional, an empty security requirement ({}) can be included in the array. */
|
|
27
|
-
security: Type.Optional(Type.Array(SecurityRequirementObject)),
|
|
28
|
-
/** A list of tags used by the OpenAPI Description with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. */
|
|
29
|
-
tags: Type.Optional(Type.Array(TagObject)),
|
|
30
|
-
/** Additional external documentation. */
|
|
31
|
-
externalDocs: Type.Optional(ExternalDocumentationObject),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export type OpenApiDocument = Static<typeof OpenAPIDocumentSchema>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Type } from '@sinclair/typebox'
|
|
2
|
-
import { ExternalDocumentationObject } from './external-documentation'
|
|
3
|
-
import { ParameterObject } from './parameter'
|
|
4
|
-
import { ReferenceObject } from './reference'
|
|
5
|
-
import { RequestBodyObject } from './request-body'
|
|
6
|
-
import { ResponsesObject } from './responses'
|
|
7
|
-
import { SecurityRequirementObject } from './security-requirement'
|
|
8
|
-
import { ServerObject } from './server'
|
|
9
|
-
|
|
10
|
-
/** Describes a single API operation on a path. */
|
|
11
|
-
export const OperationObjectWithoutCallback = Type.Union([
|
|
12
|
-
Type.Object({
|
|
13
|
-
/** A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. */
|
|
14
|
-
tags: Type.Optional(Type.Array(Type.String())),
|
|
15
|
-
/** A short summary of what the operation does. */
|
|
16
|
-
summary: Type.Optional(Type.String()),
|
|
17
|
-
/** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */
|
|
18
|
-
description: Type.Optional(Type.String()),
|
|
19
|
-
/** Additional external documentation for this operation. */
|
|
20
|
-
externalDocs: Type.Optional(ExternalDocumentationObject),
|
|
21
|
-
/** Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions. */
|
|
22
|
-
operationId: Type.Optional(Type.String()),
|
|
23
|
-
/** A list of parameters that are applicable for this operation. If a parameter is already defined at the Path Item, the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the Reference Object to link to parameters that are defined in the OpenAPI Object's components.parameters. */
|
|
24
|
-
parameters: Type.Optional(Type.Array(Type.Union([ParameterObject, ReferenceObject]))),
|
|
25
|
-
/** The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined semantics and SHOULD be avoided if possible. */
|
|
26
|
-
requestBody: Type.Optional(Type.Union([RequestBodyObject, ReferenceObject])),
|
|
27
|
-
/** The list of possible responses as they are returned from executing this operation. */
|
|
28
|
-
responses: Type.Optional(ResponsesObject),
|
|
29
|
-
/** Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is false. */
|
|
30
|
-
deprecated: Type.Optional(Type.Boolean()),
|
|
31
|
-
/** A declaration of which security mechanisms can be used for this operation. The list of values includes alternative Security Requirement Objects that can be used. Only one of the Security Requirement Objects need to be satisfied to authorize a request. To make security optional, an empty security requirement ({}) can be included in the array. This definition overrides any declared top-level security. To remove a top-level security declaration, an empty array can be used. */
|
|
32
|
-
security: Type.Optional(Type.Array(SecurityRequirementObject)),
|
|
33
|
-
/** An alternative servers array to service this operation. If a servers array is specified at the Path Item Object or OpenAPI Object level, it will be overridden by this value. */
|
|
34
|
-
servers: Type.Optional(Type.Array(ServerObject)),
|
|
35
|
-
}),
|
|
36
|
-
ReferenceObject,
|
|
37
|
-
])
|