@kubb/swagger-ts 2.0.0-canary.20231030T125204 → 2.0.1

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.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/dist/chunk-N6FDP2EJ.cjs +784 -0
  3. package/dist/chunk-N6FDP2EJ.cjs.map +1 -0
  4. package/dist/chunk-TCUL2H74.js +757 -0
  5. package/dist/chunk-TCUL2H74.js.map +1 -0
  6. package/dist/components.cjs +20 -0
  7. package/dist/components.cjs.map +1 -0
  8. package/dist/components.d.cts +69 -0
  9. package/dist/components.d.ts +69 -0
  10. package/dist/components.js +6 -0
  11. package/dist/components.js.map +1 -0
  12. package/dist/index-sycg8owy.d.cts +392 -0
  13. package/dist/index-sycg8owy.d.ts +392 -0
  14. package/dist/index.cjs +14 -652
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +11 -78
  17. package/dist/index.d.ts +11 -78
  18. package/dist/index.js +3 -625
  19. package/dist/index.js.map +1 -1
  20. package/dist/oas.cjs +4 -0
  21. package/dist/oas.cjs.map +1 -0
  22. package/dist/oas.d.cts +6 -0
  23. package/dist/oas.d.ts +6 -0
  24. package/dist/oas.js +5 -0
  25. package/dist/oas.js.map +1 -0
  26. package/dist/types-IAThMYCO.d.cts +105 -0
  27. package/dist/types-IAThMYCO.d.ts +105 -0
  28. package/package.json +27 -18
  29. package/src/OperationGenerator.tsx +63 -0
  30. package/src/TypeBuilder.ts +58 -0
  31. package/src/TypeGenerator.ts +396 -0
  32. package/src/components/Mutation.tsx +138 -0
  33. package/src/components/Oas.tsx +84 -0
  34. package/src/components/Query.tsx +137 -0
  35. package/src/components/index.ts +3 -0
  36. package/src/index.ts +6 -0
  37. package/src/oas/index.ts +7 -0
  38. package/src/oas/infer.ts +58 -0
  39. package/src/oas/mappers.ts +93 -0
  40. package/src/oas/model.ts +38 -0
  41. package/src/oas/requestParams.ts +170 -0
  42. package/src/oas/response.ts +39 -0
  43. package/src/oas/security.ts +158 -0
  44. package/src/plugin.ts +174 -0
  45. package/src/types.ts +110 -0
  46. package/dist/hooks.cjs +0 -656
  47. package/dist/hooks.cjs.map +0 -1
  48. package/dist/hooks.d.cts +0 -6
  49. package/dist/hooks.d.ts +0 -6
  50. package/dist/hooks.js +0 -634
  51. package/dist/hooks.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ import transformers from '@kubb/core/transformers'
2
+ import { print } from '@kubb/parser'
3
+ import * as factory from '@kubb/parser/factory'
4
+ import { File, usePlugin, usePluginManager } from '@kubb/react'
5
+ import { useOas, useOperation, useOperationFile, useOperationName, useSchemas } from '@kubb/swagger/hooks'
6
+
7
+ import { TypeBuilder } from '../TypeBuilder.ts'
8
+
9
+ import type { KubbFile } from '@kubb/core'
10
+ import type { ts } from '@kubb/parser'
11
+ import type { OperationSchemas } from '@kubb/swagger'
12
+ import type { Operation } from '@kubb/swagger/oas'
13
+ import type { ReactNode } from 'react'
14
+ import type { FileMeta, PluginOptions } from '../types.ts'
15
+
16
+ type Props = {
17
+ builder: TypeBuilder
18
+ }
19
+
20
+ function printCombinedSchema(name: string, operation: Operation, schemas: OperationSchemas): string {
21
+ const properties: Record<string, ts.TypeNode> = {
22
+ 'response': factory.createTypeReferenceNode(
23
+ factory.createIdentifier(schemas.response.name),
24
+ undefined,
25
+ ),
26
+ }
27
+
28
+ if (schemas.request) {
29
+ properties['request'] = factory.createTypeReferenceNode(
30
+ factory.createIdentifier(schemas.request.name),
31
+ undefined,
32
+ )
33
+ }
34
+
35
+ if (schemas.pathParams) {
36
+ properties['pathParams'] = factory.createTypeReferenceNode(
37
+ factory.createIdentifier(schemas.pathParams.name),
38
+ undefined,
39
+ )
40
+ }
41
+
42
+ if (schemas.queryParams) {
43
+ properties['queryParams'] = factory.createTypeReferenceNode(
44
+ factory.createIdentifier(schemas.queryParams.name),
45
+ undefined,
46
+ )
47
+ }
48
+
49
+ if (schemas.headerParams) {
50
+ properties['headerParams'] = factory.createTypeReferenceNode(
51
+ factory.createIdentifier(schemas.headerParams.name),
52
+ undefined,
53
+ )
54
+ }
55
+
56
+ if (schemas.errors) {
57
+ properties['errors'] = factory.createUnionDeclaration({
58
+ nodes: schemas.errors.map(error => {
59
+ return factory.createTypeReferenceNode(
60
+ factory.createIdentifier(error.name),
61
+ undefined,
62
+ )
63
+ }),
64
+ })!
65
+ }
66
+
67
+ const namespaceNode = factory.createNamespaceDeclaration({
68
+ name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,
69
+ statements: Object.keys(properties).map(key => {
70
+ const type = properties[key]
71
+ if (!type) {
72
+ return undefined
73
+ }
74
+ return factory.createTypeAliasDeclaration({
75
+ modifiers: [factory.modifiers.export],
76
+ name: transformers.pascalCase(key),
77
+ type,
78
+ })
79
+ }).filter(Boolean),
80
+ })
81
+
82
+ return print(namespaceNode)
83
+ }
84
+
85
+ export function Query({
86
+ builder,
87
+ }: Props): ReactNode {
88
+ const { source } = builder.build()
89
+
90
+ return (
91
+ <>
92
+ {source}
93
+ </>
94
+ )
95
+ }
96
+
97
+ type FileProps = {
98
+ mode: KubbFile.Mode
99
+ }
100
+
101
+ Query.File = function({ mode }: FileProps): ReactNode {
102
+ const { options } = usePlugin<PluginOptions>()
103
+
104
+ const schemas = useSchemas()
105
+ const pluginManager = usePluginManager()
106
+ const oas = useOas()
107
+ const file = useOperationFile()
108
+ const factoryName = useOperationName({ type: 'type' })
109
+ const operation = useOperation()
110
+
111
+ const builder = new TypeBuilder(options, { oas, pluginManager })
112
+ .add(schemas.pathParams)
113
+ .add(schemas.queryParams)
114
+ .add(schemas.headerParams)
115
+ .add(schemas.response)
116
+ .add(schemas.errors)
117
+
118
+ const { source, imports } = builder.build()
119
+
120
+ return (
121
+ <>
122
+ <File<FileMeta>
123
+ baseName={file.baseName}
124
+ path={file.path}
125
+ meta={file.meta}
126
+ >
127
+ {mode === 'directory' && imports.map((item, index) => {
128
+ return <File.Import key={index} root={file.path} {...item} />
129
+ })}
130
+ <File.Source>
131
+ {source}
132
+ {printCombinedSchema(factoryName, operation, schemas)}
133
+ </File.Source>
134
+ </File>
135
+ </>
136
+ )
137
+ }
@@ -0,0 +1,3 @@
1
+ export { Mutation } from './Mutation.tsx'
2
+ export { Oas } from './Oas.tsx'
3
+ export { Query } from './Query.tsx'
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { definePlugin } from './plugin.ts'
2
+
3
+ export { definePlugin, pluginKey, pluginName } from './plugin.ts'
4
+ export type * from './types.ts'
5
+
6
+ export default definePlugin
@@ -0,0 +1,7 @@
1
+ // based on https://github.com/ardatan/feTS/tree/master
2
+
3
+ export type { Infer } from './infer.ts'
4
+ export type { MethodMap, PathMap, StatusMap } from './mappers.ts'
5
+ export type { Model } from './model.ts'
6
+ export type { RequestParams } from './requestParams.ts'
7
+ export type { Response } from './response.ts'
@@ -0,0 +1,58 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ import type { Booleans, Call, Objects, Strings, Tuples } from 'hotscript'
3
+ import type { Object } from 'ts-toolbelt'
4
+
5
+ namespace Checks {
6
+ export type AllOFf = { allOf: any[] }
7
+ export type Object = {
8
+ type: 'object'
9
+ properties: any
10
+ }
11
+ export type Properties = { properties: any }
12
+ export type PropertiesRequired = {
13
+ properties: Record<string, any>
14
+ required: string[]
15
+ }
16
+ }
17
+
18
+ type FixAdditionalPropertiesForAllOf<T> = T extends Checks.AllOFf ? Omit<T, 'allOf'> & {
19
+ allOf: Call<Tuples.Map<Objects.Omit<'additionalProperties'>>, T['allOf']>
20
+ }
21
+ : T
22
+
23
+ type FixMissingAdditionalProperties<T> = T extends Checks.Object ? Omit<T, 'additionalProperties'> & { additionalProperties: false }
24
+ : T
25
+ type FixMissingTypeObject<T> = T extends Checks.Properties ? T & { type: 'object' } : T
26
+
27
+ type FixExtraRequiredFields<T> = T extends Checks.PropertiesRequired ? Omit<T, 'required'> & {
28
+ required: Call<Tuples.Filter<Booleans.Extends<keyof T['properties']>>, T['required']>
29
+ }
30
+ : T
31
+
32
+ // Later suggest using json-machete
33
+ type FixJSONSchema<T> = FixAdditionalPropertiesForAllOf<
34
+ FixMissingAdditionalProperties<FixMissingTypeObject<FixExtraRequiredFields<T>>>
35
+ >
36
+
37
+ type Mutable<Type> = FixJSONSchema<
38
+ {
39
+ -readonly [Key in keyof Type]: Mutable<Type[Key]>
40
+ }
41
+ >
42
+
43
+ type RefToPath<T extends string> = T extends `#/${infer Ref}` ? Call<Strings.Split<'/'>, Ref>
44
+ : never
45
+
46
+ type ResolveRef<TObj, TRef extends string> = {
47
+ $id: TRef
48
+ } & Object.Path<TObj, RefToPath<TRef>>
49
+
50
+ type ResolveRefInObj<T, TBase> = T extends { $ref: infer Ref } ? Ref extends string ? ResolveRef<TBase, Ref>
51
+ : T
52
+ : T
53
+
54
+ type ResolveRefsInObj<T, TBase = T> = {
55
+ [K in keyof T]: ResolveRefsInObj<ResolveRefInObj<T[K], TBase>, TBase>
56
+ }
57
+
58
+ export type Infer<TOAS> = Mutable<ResolveRefsInObj<TOAS>>
@@ -0,0 +1,93 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
2
+ /* eslint-disable @typescript-eslint/no-namespace */
3
+ import type { OasTypes } from '@kubb/swagger/oas'
4
+ import type { Fn, Pipe, Tuples } from 'hotscript'
5
+ import type {
6
+ FromSchema,
7
+ JSONSchema,
8
+ } from 'json-schema-to-ts'
9
+
10
+ namespace Checks {
11
+ export type Required = { required: true }
12
+
13
+ export type Schemas = {
14
+ schema: JSONSchema
15
+ }
16
+ export type Enum = { type: JSONSchemaTypeName; enum?: any[] }
17
+ export type Parameters = { in: string; required?: boolean }[]
18
+ export type SingleParameter<TParamType> = [{ in: TParamType; required?: true }]
19
+ export type Responses = { responses: any }
20
+ }
21
+
22
+ export type PathMap<TOAS extends OasTypes.OASDocument> = TOAS['paths']
23
+
24
+ interface ParamPropMap {
25
+ query: 'query'
26
+ path: 'params'
27
+ header: 'headers'
28
+ }
29
+
30
+ type JSONSchemaTypeName =
31
+ | 'string'
32
+ | 'number'
33
+ | 'integer'
34
+ | 'boolean'
35
+ | 'object'
36
+ | 'array'
37
+ | 'null'
38
+
39
+ type ParamObj<
40
+ TParameter extends {
41
+ name: string
42
+ },
43
+ > = TParameter extends Checks.Required ? {
44
+ [TName in TParameter['name']]: TParameter extends Checks.Schemas ? FromSchema<TParameter['schema']>
45
+ : TParameter extends Checks.Enum ? FromSchema<{
46
+ type: TParameter['type']
47
+ enum: TParameter['enum']
48
+ }>
49
+ : unknown
50
+ }
51
+ : {
52
+ [TName in TParameter['name']]?: TParameter extends Checks.Schemas ? FromSchema<TParameter['schema']>
53
+ : TParameter extends Checks.Enum ? FromSchema<{
54
+ type: TParameter['type']
55
+ enum: TParameter['enum']
56
+ }>
57
+ : unknown
58
+ }
59
+
60
+ interface ParamToRequestParam<TParameters extends Checks.Parameters> extends Fn {
61
+ return: this['arg0'] extends { name: string; in: infer TParamType }
62
+ // If there is any required parameter for this parameter type, make that parameter type required
63
+ ? TParameters extends Checks.SingleParameter<TParamType> ? {
64
+ [
65
+ TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType]
66
+ : never
67
+ ]: ParamObj<this['arg0']>
68
+ }
69
+ : {
70
+ [
71
+ TKey in TParamType extends keyof ParamPropMap ? ParamPropMap[TParamType]
72
+ : never
73
+ ]?: ParamObj<this['arg0']>
74
+ }
75
+ : {}
76
+ }
77
+
78
+ export type ParamMap<TParameters extends Checks.Parameters> = Pipe<
79
+ TParameters,
80
+ [Tuples.Map<ParamToRequestParam<TParameters>>, Tuples.ToIntersection]
81
+ >
82
+
83
+ export type MethodMap<
84
+ TOAS extends OasTypes.OASDocument,
85
+ TPath extends keyof PathMap<TOAS>,
86
+ > = PathMap<TOAS>[TPath]
87
+
88
+ export type StatusMap<
89
+ TOAS extends OasTypes.OASDocument,
90
+ TPath extends keyof PathMap<TOAS>,
91
+ TMethod extends keyof MethodMap<TOAS, TPath>,
92
+ > = MethodMap<TOAS, TPath>[TMethod] extends Checks.Responses ? MethodMap<TOAS, TPath>[TMethod]['responses']
93
+ : never
@@ -0,0 +1,38 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ import type { OasTypes } from '@kubb/swagger/oas'
3
+ import type {
4
+ FromSchema,
5
+ JSONSchema,
6
+ } from 'json-schema-to-ts'
7
+
8
+ namespace Checks {
9
+ export type ModelWithSchemas = {
10
+ components: {
11
+ schemas: Record<string, JSONSchema>
12
+ }
13
+ }
14
+ export type ModelWithSchemasNamed<TName extends string | number | symbol> = {
15
+ components: {
16
+ schemas: {
17
+ [TModelName in TName]: JSONSchema
18
+ }
19
+ }
20
+ }
21
+ export type ModelWithDefinitions = {
22
+ definitions: Record<string, JSONSchema>
23
+ }
24
+ export type ModelWithDefinitionsNamed<TName extends string | number | symbol = never> = {
25
+ definitions: {
26
+ [TModelName in TName]: JSONSchema
27
+ }
28
+ }
29
+ }
30
+
31
+ export type Model<
32
+ TOAS extends OasTypes.OASDocument,
33
+ TName extends TOAS extends Checks.ModelWithSchemas ? keyof TOAS['components']['schemas']
34
+ : TOAS extends Checks.ModelWithDefinitions ? keyof TOAS['definitions']
35
+ : never,
36
+ > = TOAS extends Checks.ModelWithSchemasNamed<TName> ? FromSchema<TOAS['components']['schemas'][TName]>
37
+ : TOAS extends Checks.ModelWithDefinitionsNamed<TName> ? FromSchema<TOAS['definitions'][TName]>
38
+ : never
@@ -0,0 +1,170 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ /* eslint-disable @typescript-eslint/ban-types */
3
+
4
+ import type { OasTypes } from '@kubb/swagger/oas'
5
+ import type { SplitByDelimiter, TupleToUnion } from '@kubb/types'
6
+ import type { Pipe, Strings, Tuples } from 'hotscript'
7
+ import type {
8
+ FromSchema,
9
+ JSONSchema,
10
+ } from 'json-schema-to-ts'
11
+ import type { MethodMap, ParamMap, PathMap } from './mappers.ts'
12
+ import type { SecurityParamsBySecurityRef } from './security.ts'
13
+
14
+ namespace Checks {
15
+ export type RequestBodyJson = {
16
+ requestBody: { content: { 'application/json': { schema: JSONSchema } } }
17
+ }
18
+ export type RequestBodyFormData = {
19
+ requestBody: {
20
+ content: { 'multipart/form-data': { schema: JSONSchema } }
21
+ }
22
+ }
23
+ export type RequestBodyFormEncoded = {
24
+ requestBody: {
25
+ content: {
26
+ 'application/x-www-form-urlencoded': { schema: JSONSchema }
27
+ }
28
+ }
29
+ }
30
+ export type Parameters = {
31
+ parameters: { name: string; in: string }[]
32
+ }
33
+ export type PathBrackets = `${string}{${string}}${string}`
34
+ export type PathPattern = `${string}:${string}${string}`
35
+ export type Required = { required: true }
36
+ }
37
+
38
+ type ExtractPathParamsWithPattern<TPath extends string> = Pipe<
39
+ TPath,
40
+ [
41
+ Strings.Split<'/'>,
42
+ Tuples.Filter<Strings.StartsWith<':'>>,
43
+ Tuples.Map<Strings.Trim<':'>>,
44
+ Tuples.ToUnion,
45
+ ]
46
+ >
47
+
48
+ type IsPathParameter<T extends string> = T extends `{${infer U}}` ? U : never
49
+
50
+ type ExtractPathParameters<T extends any[]> = {
51
+ [K in keyof T]: IsPathParameter<T[K]>
52
+ }
53
+
54
+ type ExtractSegments<TPath extends string> = SplitByDelimiter<TPath, '/'>
55
+
56
+ type ExtractSubSegments<T extends any[]> = {
57
+ [K in keyof T]: SplitByDelimiter<T[K], ';'>
58
+ }
59
+
60
+ type ExtractPathParamsWithBrackets<TPath extends string> = TupleToUnion<
61
+ ExtractPathParameters<ExtractSubSegments<ExtractSegments<TPath>>[number]>
62
+ >
63
+
64
+ export type RequestParams<
65
+ TOAS extends OasTypes.OASDocument,
66
+ TPath extends keyof PathMap<TOAS>,
67
+ TMethod extends keyof MethodMap<TOAS, TPath>,
68
+ > =
69
+ & (MethodMap<TOAS, TPath>[TMethod] extends Checks.RequestBodyJson ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks.Required ? {
70
+ /**
71
+ * The request body in JSON is required for this request.
72
+ *
73
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
74
+ */
75
+ json: FromSchema<
76
+ MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']
77
+ >
78
+ }
79
+ : {
80
+ /**
81
+ * The request body in JSON is optional for this request.
82
+ *
83
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
84
+ */
85
+ json?: FromSchema<
86
+ MethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']
87
+ >
88
+ }
89
+ : MethodMap<TOAS, TPath>[TMethod] extends Checks.RequestBodyFormData ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks.Required ? {
90
+ /**
91
+ * The request body in multipart/form-data is required for this request.
92
+ *
93
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
94
+ */
95
+ formData: FromSchema<
96
+ MethodMap<
97
+ TOAS,
98
+ TPath
99
+ >[TMethod]['requestBody']['content']['multipart/form-data']['schema']
100
+ >
101
+ }
102
+ : {
103
+ /**
104
+ * The request body in multipart/form-data is optional for this request.
105
+ *
106
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
107
+ */
108
+ formData?: FromSchema<
109
+ MethodMap<
110
+ TOAS,
111
+ TPath
112
+ >[TMethod]['requestBody']['content']['multipart/form-data']['schema']
113
+ >
114
+ }
115
+ : MethodMap<TOAS, TPath>[TMethod] extends Checks.RequestBodyFormEncoded ? MethodMap<TOAS, TPath>[TMethod]['requestBody'] extends Checks.Required ? {
116
+ /**
117
+ * The request body in application/x-www-form-urlencoded is required for this request.
118
+ *
119
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
120
+ */
121
+ formUrlEncoded: FromSchema<
122
+ MethodMap<
123
+ TOAS,
124
+ TPath
125
+ >[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']
126
+ >
127
+ }
128
+ : {
129
+ /**
130
+ * The request body in application/x-www-form-urlencoded is optional for this request.
131
+ *
132
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
133
+ */
134
+ formUrlEncoded?: FromSchema<
135
+ MethodMap<
136
+ TOAS,
137
+ TPath
138
+ >[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']
139
+ >
140
+ }
141
+ : {})
142
+ & (MethodMap<TOAS, TPath>[TMethod] extends Checks.Parameters ? ParamMap<MethodMap<TOAS, TPath>[TMethod]['parameters']>
143
+ : {})
144
+ & // If there is any parameters defined in path but not in the parameters array, we should add them to the params
145
+ (TPath extends Checks.PathBrackets ? {
146
+ /**
147
+ * Parameters defined in the path are required for this request.
148
+ *
149
+ * The value of `params` will be used to replace the path parameters.
150
+ *
151
+ * For example if path is `/todos/{id}` and `params` is `{ id: '1' }`, the path will be `/todos/1`
152
+ */
153
+ params: Record<ExtractPathParamsWithBrackets<TPath>, string | number | bigint | boolean>
154
+ }
155
+ : {})
156
+ & (TPath extends Checks.PathPattern ? {
157
+ /**
158
+ * Parameters defined in the path are required for this request.
159
+ *
160
+ * The value of `params` will be used to replace the path parameters.
161
+ *
162
+ * For example if path is `/todos/:id` and `params` is `{ id: '1' }`, the path will be `/todos/1`.
163
+ */
164
+ params: Record<ExtractPathParamsWithPattern<TPath>, string | number | bigint | boolean>
165
+ }
166
+ : {})
167
+ & // Respect security definitions in path object
168
+ SecurityParamsBySecurityRef<TOAS, MethodMap<TOAS, TPath>[TMethod]>
169
+ & // Respect global security definitions
170
+ SecurityParamsBySecurityRef<TOAS, TOAS>
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ import type { OasTypes } from '@kubb/swagger/oas'
3
+ import type {
4
+ FromSchema,
5
+ } from 'json-schema-to-ts'
6
+ import type { MethodMap, PathMap, StatusMap } from './mappers.ts'
7
+
8
+ namespace Checks {
9
+ export type Content = { content: any }
10
+ }
11
+
12
+ type ResponseSchemas<
13
+ TOAS extends OasTypes.OASDocument,
14
+ TPath extends keyof PathMap<TOAS>,
15
+ TMethod extends keyof MethodMap<TOAS, TPath>,
16
+ TStatus extends keyof StatusMap<TOAS, TPath, TMethod>,
17
+ > = StatusMap<TOAS, TPath, TMethod>[TStatus]['content']
18
+
19
+ type JSONResponseSchema<
20
+ TOAS extends OasTypes.OASDocument,
21
+ TPath extends keyof PathMap<TOAS>,
22
+ TMethod extends keyof MethodMap<TOAS, TPath>,
23
+ TStatus extends keyof StatusMap<TOAS, TPath, TMethod>,
24
+ > = StatusMap<TOAS, TPath, TMethod>[TStatus] extends Checks.Content ? ResponseSchemas<TOAS, TPath, TMethod, TStatus>[
25
+ keyof ResponseSchemas<
26
+ TOAS,
27
+ TPath,
28
+ TMethod,
29
+ TStatus
30
+ >
31
+ ]['schema']
32
+ : StatusMap<TOAS, TPath, TMethod>[TStatus]['schema']
33
+
34
+ export type Response<
35
+ TOAS extends OasTypes.OASDocument,
36
+ TPath extends keyof PathMap<TOAS>,
37
+ TMethod extends keyof MethodMap<TOAS, TPath>,
38
+ TStatusCode extends keyof StatusMap<TOAS, TPath, TMethod> = 200,
39
+ > = FromSchema<JSONResponseSchema<TOAS, TPath, TMethod, TStatusCode>>