@danceroutine/tango-openapi 0.1.0 → 1.0.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/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/chunk-BkvOhyD0.js +12 -0
- package/dist/domain/describeResources.d.ts +10 -0
- package/dist/domain/index.d.ts +2 -1
- package/dist/domain/index.js +3 -4
- package/dist/domain/types.d.ts +76 -12
- package/dist/domain-B-7sApJT.js +34 -0
- package/dist/domain-B-7sApJT.js.map +1 -0
- package/dist/generators/index.js +2 -2
- package/dist/generators/spec/generateOpenAPISpec.d.ts +3 -0
- package/dist/generators-JMALItMS.js +346 -0
- package/dist/generators-JMALItMS.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -10
- package/dist/mappers/index.d.ts +1 -1
- package/dist/mappers/index.js +3 -3
- package/dist/mappers/schema/generateSchemaFromModel.d.ts +3 -0
- package/dist/mappers/schema/generateSchemaFromZod.d.ts +6 -0
- package/dist/mappers/schema/index.d.ts +1 -0
- package/dist/mappers/schema/mapTypeToOpenAPI.d.ts +3 -0
- package/dist/mappers-bmN95TGV.js +15 -0
- package/dist/{mappers-CIfnOwl2.js.map → mappers-bmN95TGV.js.map} +1 -1
- package/dist/{schema-DVxdID48.js → schema-D3ybOrpr.js} +19 -12
- package/dist/schema-D3ybOrpr.js.map +1 -0
- package/package.json +57 -53
- package/dist/domain/types.js +0 -1
- package/dist/domain-Cufz6y1q.js +0 -7
- package/dist/domain-Cufz6y1q.js.map +0 -1
- package/dist/generators/spec/generateOpenAPISpec.js +0 -133
- package/dist/generators-Bvwyyja4.js +0 -131
- package/dist/generators-Bvwyyja4.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mappers/schema/generateSchemaFromModel.js +0 -19
- package/dist/mappers-CIfnOwl2.js +0 -13
- package/dist/schema-DVxdID48.js.map +0 -1
- package/dist/version.d.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pedro Del Moral Lopez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# @danceroutine/tango-openapi
|
|
2
|
+
|
|
3
|
+
`@danceroutine/tango-openapi` generates OpenAPI 3.1 documents from Tango resource instances. It works best when an application already expresses its HTTP contract through `ModelViewSet`, `GenericAPIView`, or `APIView`.
|
|
4
|
+
|
|
5
|
+
Applications usually keep a small `openapi.ts` module that instantiates the resources they want to document, passes them through the descriptor helpers, and serves the generated document through Express or Next.js.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @danceroutine/tango-openapi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use this package when you want to:
|
|
14
|
+
|
|
15
|
+
- generate an OpenAPI 3.1 document from Tango resources
|
|
16
|
+
- derive request and response schemas from Zod-backed resource contracts
|
|
17
|
+
- publish a JSON document to Swagger UI, client generators, or external tooling
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
import {
|
|
24
|
+
describeAPIView,
|
|
25
|
+
describeGenericAPIView,
|
|
26
|
+
describeViewSet,
|
|
27
|
+
generateOpenAPISpec,
|
|
28
|
+
type OpenAPISpec,
|
|
29
|
+
} from '@danceroutine/tango-openapi';
|
|
30
|
+
import { HealthAPIView, PostDetailAPIView, PostViewSet } from './resources';
|
|
31
|
+
|
|
32
|
+
export function createOpenAPISpec(): OpenAPISpec {
|
|
33
|
+
return generateOpenAPISpec({
|
|
34
|
+
title: 'Blog API',
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
description: 'OpenAPI document generated from Tango resource instances.',
|
|
37
|
+
resources: [
|
|
38
|
+
describeViewSet({
|
|
39
|
+
basePath: '/api/posts',
|
|
40
|
+
resource: new PostViewSet(),
|
|
41
|
+
}),
|
|
42
|
+
describeGenericAPIView({
|
|
43
|
+
resource: new PostDetailAPIView(),
|
|
44
|
+
detailPath: '/api/posts-generic/{id}',
|
|
45
|
+
}),
|
|
46
|
+
describeAPIView({
|
|
47
|
+
path: '/api/healthz',
|
|
48
|
+
resource: new HealthAPIView(),
|
|
49
|
+
methods: {
|
|
50
|
+
GET: {
|
|
51
|
+
summary: 'Health check',
|
|
52
|
+
responseSchema: z.object({
|
|
53
|
+
status: z.literal('ok'),
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`describeViewSet()` documents the standard CRUD surface and any custom actions the viewset exposes. `describeGenericAPIView()` documents collection and detail routes for a generic resource. `describeAPIView()` covers fully custom endpoints where application code supplies the operation metadata directly.
|
|
64
|
+
|
|
65
|
+
The generated object is ready to publish through whichever host framework owns your HTTP layer.
|
|
66
|
+
|
|
67
|
+
Express:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { createOpenAPISpec } from './openapi';
|
|
71
|
+
|
|
72
|
+
app.get('/api/openapi.json', (_req, res) => {
|
|
73
|
+
res.json(createOpenAPISpec());
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Next.js App Router:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { createOpenAPISpec } from '@/lib/openapi';
|
|
81
|
+
|
|
82
|
+
export async function GET(): Promise<Response> {
|
|
83
|
+
return Response.json(createOpenAPISpec());
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## What the generator emits
|
|
88
|
+
|
|
89
|
+
For a `ModelViewSet`, `generateOpenAPISpec()` emits:
|
|
90
|
+
|
|
91
|
+
- `GET /<path>`
|
|
92
|
+
- `POST /<path>`
|
|
93
|
+
- `GET /<path>/{id}`
|
|
94
|
+
- `PUT /<path>/{id}`
|
|
95
|
+
- `PATCH /<path>/{id}`
|
|
96
|
+
- `DELETE /<path>/{id}`
|
|
97
|
+
|
|
98
|
+
When the viewset defines custom actions, the generator also emits those routes using the resolved action paths from the resource itself.
|
|
99
|
+
|
|
100
|
+
For `GenericAPIView`, the generator documents whichever collection and detail paths the descriptor supplies. For plain `APIView`, the generator uses the manual operation metadata passed to `describeAPIView()`.
|
|
101
|
+
|
|
102
|
+
The package also generates component schemas from Tango model metadata and Zod schemas when those are available through the resource contract.
|
|
103
|
+
|
|
104
|
+
## Current boundary
|
|
105
|
+
|
|
106
|
+
The package documents Tango resources directly and covers the built-in CRUD surface, generic view routes, and custom action paths. Richer custom action request and response details still come from explicit overrides, and plain `APIView` routes still need manual method metadata because Tango cannot infer those HTTP contracts from the class alone.
|
|
107
|
+
|
|
108
|
+
`generateSchemaFromModel()` and `generateSchemaFromZod()` remain useful when an application needs schema generation outside full document generation.
|
|
109
|
+
|
|
110
|
+
## Public API
|
|
111
|
+
|
|
112
|
+
The root export includes:
|
|
113
|
+
|
|
114
|
+
- `generateOpenAPISpec()`
|
|
115
|
+
- `describeViewSet()`
|
|
116
|
+
- `describeGenericAPIView()`
|
|
117
|
+
- `describeAPIView()`
|
|
118
|
+
- `generateSchemaFromModel()`
|
|
119
|
+
- `generateSchemaFromZod()`
|
|
120
|
+
- `mapTypeToOpenAPI()`
|
|
121
|
+
|
|
122
|
+
The root export is enough for normal application use. The `domain`, `generators`, and `mappers` subpaths are useful when you want a narrower import boundary.
|
|
123
|
+
|
|
124
|
+
## Documentation
|
|
125
|
+
|
|
126
|
+
- Official documentation: <https://tangowebframework.dev>
|
|
127
|
+
- Publish an OpenAPI document: <https://tangowebframework.dev/how-to/publish-openapi-document>
|
|
128
|
+
- OpenAPI API reference: <https://tangowebframework.dev/reference/openapi-api>
|
|
129
|
+
- Resources topic: <https://tangowebframework.dev/topics/resources-and-viewsets>
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm --filter @danceroutine/tango-openapi build
|
|
135
|
+
pnpm --filter @danceroutine/tango-openapi typecheck
|
|
136
|
+
pnpm --filter @danceroutine/tango-openapi test
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For the wider contributor workflow, use:
|
|
140
|
+
|
|
141
|
+
- <https://tangowebframework.dev/contributing>
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { APIViewMethod, ModelSerializerClass, SerializerSchema } from '@danceroutine/tango-resources';
|
|
2
|
+
import type { OpenAPIViewSetDescriptor, OpenAPIGenericAPIViewDescriptor, OpenAPIAPIViewDescriptor } from './types';
|
|
3
|
+
export declare function describeViewSet(descriptor: Omit<OpenAPIViewSetDescriptor, 'kind'>): OpenAPIViewSetDescriptor;
|
|
4
|
+
export declare function describeViewSet<TModel extends Record<string, unknown>, TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>>(descriptor: Omit<OpenAPIViewSetDescriptor<TModel, TSerializer>, 'kind'>): OpenAPIViewSetDescriptor<TModel, TSerializer>;
|
|
5
|
+
export declare function describeGenericAPIView(descriptor: Omit<OpenAPIGenericAPIViewDescriptor, 'kind'>): OpenAPIGenericAPIViewDescriptor;
|
|
6
|
+
export declare function describeGenericAPIView<TModel extends Record<string, unknown>, TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>>(descriptor: Omit<OpenAPIGenericAPIViewDescriptor<TModel, TSerializer>, 'kind'>): OpenAPIGenericAPIViewDescriptor<TModel, TSerializer>;
|
|
7
|
+
export declare function describeAPIView(descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'>): OpenAPIAPIViewDescriptor;
|
|
8
|
+
export declare function describeAPIView<TMethods extends Partial<Record<APIViewMethod, OpenAPIAPIViewDescriptor['methods'][APIViewMethod]>>>(descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'> & {
|
|
9
|
+
methods: TMethods;
|
|
10
|
+
}): OpenAPIAPIViewDescriptor;
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Domain boundary barrel: centralizes this subdomain's public contract.
|
|
3
3
|
*/
|
|
4
|
-
export type { ComponentsObject, MediaTypeObject, OperationObject, OpenAPIModel, OpenAPIModelFieldMeta, OpenAPIOptions, OpenAPISpec, OpenAPIGeneratorConfig, ParameterObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject,
|
|
4
|
+
export type { ComponentsObject, MediaTypeObject, OperationObject, OpenAPIAPIViewDescriptor, OpenAPIModel, OpenAPIModelFieldMeta, OpenAPIOptions, OpenAPIOperationOverride, OpenAPIResponseOverride, OpenAPIResourceDescriptor, OpenAPISchemaInput, OpenAPISpec, OpenAPIGeneratorConfig, OpenAPIGenericAPIViewDescriptor, OpenAPIViewSetDescriptor, ParameterObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, } from './types';
|
|
5
|
+
export { describeAPIView, describeGenericAPIView, describeViewSet } from './describeResources';
|
package/dist/domain/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {};
|
|
1
|
+
import { describeAPIView, describeGenericAPIView, describeViewSet } from "../domain-B-7sApJT.js";
|
|
2
|
+
|
|
3
|
+
export { describeAPIView, describeGenericAPIView, describeViewSet };
|
package/dist/domain/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { APIView, APIViewMethod, GenericAPIView, ModelSerializerClass, ModelViewSet, SerializerSchema } from '@danceroutine/tango-resources';
|
|
1
2
|
import type { z } from 'zod';
|
|
3
|
+
/** Model field metadata used by low-level model-to-schema OpenAPI generation. */
|
|
2
4
|
export type OpenAPIModelFieldMeta = {
|
|
3
5
|
type: string;
|
|
4
6
|
description?: string;
|
|
@@ -6,61 +8,99 @@ export type OpenAPIModelFieldMeta = {
|
|
|
6
8
|
default?: unknown;
|
|
7
9
|
primaryKey?: boolean;
|
|
8
10
|
};
|
|
11
|
+
/** Minimal model shape consumed by low-level OpenAPI mappers. */
|
|
9
12
|
export type OpenAPIModel = {
|
|
10
13
|
name: string;
|
|
11
14
|
fields: Record<string, OpenAPIModelFieldMeta>;
|
|
12
15
|
};
|
|
13
|
-
|
|
14
|
-
repository?: {
|
|
15
|
-
model?: OpenAPIModel;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
16
|
+
/** OpenAPI `$ref` object. */
|
|
18
17
|
export type ReferenceObject = {
|
|
19
18
|
$ref: string;
|
|
20
19
|
};
|
|
20
|
+
/** OpenAPI schema object subset used by Tango. */
|
|
21
21
|
export type SchemaObject = {
|
|
22
22
|
type?: string;
|
|
23
23
|
description?: string;
|
|
24
24
|
nullable?: boolean;
|
|
25
25
|
default?: unknown;
|
|
26
|
-
properties?: Record<string, SchemaObject>;
|
|
26
|
+
properties?: Record<string, SchemaObject | ReferenceObject>;
|
|
27
27
|
required?: string[];
|
|
28
28
|
items?: SchemaObject | ReferenceObject;
|
|
29
|
+
additionalProperties?: boolean | SchemaObject | ReferenceObject;
|
|
30
|
+
enum?: unknown[];
|
|
31
|
+
oneOf?: Array<SchemaObject | ReferenceObject>;
|
|
32
|
+
anyOf?: Array<SchemaObject | ReferenceObject>;
|
|
33
|
+
allOf?: Array<SchemaObject | ReferenceObject>;
|
|
34
|
+
format?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
29
36
|
};
|
|
37
|
+
/** Schema inputs accepted by resource-aware OpenAPI descriptors. */
|
|
38
|
+
export type OpenAPISchemaInput = z.ZodType | SchemaObject | ReferenceObject;
|
|
39
|
+
/** OpenAPI media type object. */
|
|
30
40
|
export type MediaTypeObject = {
|
|
31
41
|
schema: SchemaObject | ReferenceObject;
|
|
32
42
|
};
|
|
43
|
+
/** OpenAPI response object. */
|
|
33
44
|
export type ResponseObject = {
|
|
34
45
|
description: string;
|
|
35
46
|
content?: Record<string, MediaTypeObject>;
|
|
36
47
|
};
|
|
48
|
+
/** OpenAPI parameter object. */
|
|
37
49
|
export type ParameterObject = {
|
|
38
50
|
name: string;
|
|
39
51
|
in: 'query' | 'path' | 'header' | 'cookie';
|
|
40
52
|
required?: boolean;
|
|
41
|
-
schema: SchemaObject;
|
|
53
|
+
schema: SchemaObject | ReferenceObject;
|
|
54
|
+
description?: string;
|
|
42
55
|
};
|
|
56
|
+
/** OpenAPI request body object. */
|
|
43
57
|
export type RequestBodyObject = {
|
|
44
58
|
required?: boolean;
|
|
45
59
|
content: Record<string, MediaTypeObject>;
|
|
46
60
|
};
|
|
61
|
+
/** OpenAPI operation object subset. */
|
|
47
62
|
export type OperationObject = {
|
|
48
63
|
summary?: string;
|
|
64
|
+
description?: string;
|
|
49
65
|
tags?: string[];
|
|
50
66
|
parameters?: ParameterObject[];
|
|
51
67
|
requestBody?: RequestBodyObject;
|
|
52
68
|
responses: Record<string, ResponseObject>;
|
|
53
69
|
};
|
|
70
|
+
/** Override shape for one explicit response. */
|
|
71
|
+
export type OpenAPIResponseOverride = {
|
|
72
|
+
description: string;
|
|
73
|
+
schema?: OpenAPISchemaInput;
|
|
74
|
+
};
|
|
75
|
+
/** Override shape for one operation. */
|
|
76
|
+
export type OpenAPIOperationOverride = {
|
|
77
|
+
summary?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
tags?: string[];
|
|
80
|
+
parameters?: ParameterObject[];
|
|
81
|
+
requestBody?: {
|
|
82
|
+
required?: boolean;
|
|
83
|
+
schema: OpenAPISchemaInput;
|
|
84
|
+
};
|
|
85
|
+
responseStatus?: string;
|
|
86
|
+
responseDescription?: string;
|
|
87
|
+
responseSchema?: OpenAPISchemaInput;
|
|
88
|
+
responses?: Record<string, OpenAPIResponseOverride>;
|
|
89
|
+
};
|
|
90
|
+
/** OpenAPI path item object subset. */
|
|
54
91
|
export type PathItemObject = {
|
|
55
92
|
get?: OperationObject;
|
|
56
93
|
post?: OperationObject;
|
|
94
|
+
put?: OperationObject;
|
|
57
95
|
patch?: OperationObject;
|
|
58
96
|
delete?: OperationObject;
|
|
59
97
|
};
|
|
98
|
+
/** OpenAPI components object subset. */
|
|
60
99
|
export type ComponentsObject = {
|
|
61
100
|
schemas?: Record<string, SchemaObject>;
|
|
62
101
|
securitySchemes?: Record<string, Record<string, unknown>>;
|
|
63
102
|
};
|
|
103
|
+
/** Root OpenAPI specification document shape. */
|
|
64
104
|
export interface OpenAPISpec {
|
|
65
105
|
openapi: string;
|
|
66
106
|
info: {
|
|
@@ -75,6 +115,7 @@ export interface OpenAPISpec {
|
|
|
75
115
|
paths: Record<string, PathItemObject>;
|
|
76
116
|
components?: ComponentsObject;
|
|
77
117
|
}
|
|
118
|
+
/** Options for generating an OpenAPI spec document. */
|
|
78
119
|
export interface OpenAPIOptions {
|
|
79
120
|
title: string;
|
|
80
121
|
version: string;
|
|
@@ -84,10 +125,33 @@ export interface OpenAPIOptions {
|
|
|
84
125
|
description?: string;
|
|
85
126
|
}>;
|
|
86
127
|
}
|
|
128
|
+
export type OpenAPIViewSetDescriptor<TModel extends Record<string, unknown> = Record<string, unknown>, TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema> = ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>> = {
|
|
129
|
+
kind: 'viewset';
|
|
130
|
+
basePath: string;
|
|
131
|
+
resource: ModelViewSet<TModel, TSerializer>;
|
|
132
|
+
tags?: string[];
|
|
133
|
+
actions?: Record<string, OpenAPIOperationOverride>;
|
|
134
|
+
};
|
|
135
|
+
export type OpenAPIGenericAPIViewDescriptor<TModel extends Record<string, unknown> = Record<string, unknown>, TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema> = ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>> = {
|
|
136
|
+
kind: 'generic';
|
|
137
|
+
collectionPath?: string;
|
|
138
|
+
detailPath?: string;
|
|
139
|
+
resource: GenericAPIView<TModel, TSerializer>;
|
|
140
|
+
tags?: string[];
|
|
141
|
+
methods?: Partial<Record<APIViewMethod, OpenAPIOperationOverride>>;
|
|
142
|
+
};
|
|
143
|
+
export type OpenAPIAPIViewDescriptor = {
|
|
144
|
+
kind: 'api';
|
|
145
|
+
path: string;
|
|
146
|
+
resource: APIView;
|
|
147
|
+
tags?: string[];
|
|
148
|
+
methods: Partial<Record<APIViewMethod, OpenAPIOperationOverride>>;
|
|
149
|
+
};
|
|
150
|
+
type AnyOpenAPIViewSetDescriptor = OpenAPIViewSetDescriptor<any, any>;
|
|
151
|
+
type AnyOpenAPIGenericAPIViewDescriptor = OpenAPIGenericAPIViewDescriptor<any, any>;
|
|
152
|
+
export type OpenAPIResourceDescriptor = AnyOpenAPIViewSetDescriptor | AnyOpenAPIGenericAPIViewDescriptor | OpenAPIAPIViewDescriptor;
|
|
153
|
+
/** Extended generator configuration used by Tango's OpenAPI builder. */
|
|
87
154
|
export type OpenAPIGeneratorConfig = OpenAPIOptions & {
|
|
88
|
-
resources?:
|
|
89
|
-
path: string;
|
|
90
|
-
schema: z.ZodType;
|
|
91
|
-
}>;
|
|
92
|
-
viewsets?: Record<string, ViewSetLike>;
|
|
155
|
+
resources?: OpenAPIResourceDescriptor[];
|
|
93
156
|
};
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
|
|
3
|
+
//#region src/domain/describeResources.ts
|
|
4
|
+
function describeViewSet(descriptor) {
|
|
5
|
+
return {
|
|
6
|
+
kind: "viewset",
|
|
7
|
+
...descriptor
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function describeGenericAPIView(descriptor) {
|
|
11
|
+
return {
|
|
12
|
+
kind: "generic",
|
|
13
|
+
...descriptor
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function describeAPIView(descriptor) {
|
|
17
|
+
return {
|
|
18
|
+
kind: "api",
|
|
19
|
+
...descriptor
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/domain/index.ts
|
|
25
|
+
var domain_exports = {};
|
|
26
|
+
__export(domain_exports, {
|
|
27
|
+
describeAPIView: () => describeAPIView,
|
|
28
|
+
describeGenericAPIView: () => describeGenericAPIView,
|
|
29
|
+
describeViewSet: () => describeViewSet
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { describeAPIView, describeGenericAPIView, describeViewSet, domain_exports };
|
|
34
|
+
//# sourceMappingURL=domain-B-7sApJT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-B-7sApJT.js","names":["descriptor: Omit<OpenAPIViewSetDescriptor, 'kind'>","descriptor: Omit<OpenAPIGenericAPIViewDescriptor, 'kind'>","descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'>"],"sources":["../src/domain/describeResources.ts","../src/domain/index.ts"],"sourcesContent":["import type { APIViewMethod, ModelSerializerClass, SerializerSchema } from '@danceroutine/tango-resources';\nimport type { OpenAPIViewSetDescriptor, OpenAPIGenericAPIViewDescriptor, OpenAPIAPIViewDescriptor } from './types';\n\nexport function describeViewSet(descriptor: Omit<OpenAPIViewSetDescriptor, 'kind'>): OpenAPIViewSetDescriptor;\nexport function describeViewSet<\n TModel extends Record<string, unknown>,\n TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>,\n>(\n descriptor: Omit<OpenAPIViewSetDescriptor<TModel, TSerializer>, 'kind'>\n): OpenAPIViewSetDescriptor<TModel, TSerializer>;\nexport function describeViewSet(descriptor: Omit<OpenAPIViewSetDescriptor, 'kind'>) {\n return {\n kind: 'viewset',\n ...descriptor,\n };\n}\n\nexport function describeGenericAPIView(\n descriptor: Omit<OpenAPIGenericAPIViewDescriptor, 'kind'>\n): OpenAPIGenericAPIViewDescriptor;\nexport function describeGenericAPIView<\n TModel extends Record<string, unknown>,\n TSerializer extends ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema>,\n>(\n descriptor: Omit<OpenAPIGenericAPIViewDescriptor<TModel, TSerializer>, 'kind'>\n): OpenAPIGenericAPIViewDescriptor<TModel, TSerializer>;\nexport function describeGenericAPIView(descriptor: Omit<OpenAPIGenericAPIViewDescriptor, 'kind'>) {\n return {\n kind: 'generic',\n ...descriptor,\n };\n}\n\nexport function describeAPIView(descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'>): OpenAPIAPIViewDescriptor;\nexport function describeAPIView<\n TMethods extends Partial<Record<APIViewMethod, OpenAPIAPIViewDescriptor['methods'][APIViewMethod]>>,\n>(descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'> & { methods: TMethods }): OpenAPIAPIViewDescriptor;\nexport function describeAPIView(descriptor: Omit<OpenAPIAPIViewDescriptor, 'kind'>) {\n return {\n kind: 'api',\n ...descriptor,\n };\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type {\n ComponentsObject,\n MediaTypeObject,\n OperationObject,\n OpenAPIAPIViewDescriptor,\n OpenAPIModel,\n OpenAPIModelFieldMeta,\n OpenAPIOptions,\n OpenAPIOperationOverride,\n OpenAPIResponseOverride,\n OpenAPIResourceDescriptor,\n OpenAPISchemaInput,\n OpenAPISpec,\n OpenAPIGeneratorConfig,\n OpenAPIGenericAPIViewDescriptor,\n OpenAPIViewSetDescriptor,\n ParameterObject,\n PathItemObject,\n ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n} from './types';\nexport { describeAPIView, describeGenericAPIView, describeViewSet } from './describeResources';\n"],"mappings":";;;AAUO,SAAS,gBAAgBA,YAAoD;AAChF,QAAO;EACH,MAAM;EACN,GAAG;CACN;AACJ;AAWM,SAAS,uBAAuBC,YAA2D;AAC9F,QAAO;EACH,MAAM;EACN,GAAG;CACN;AACJ;AAMM,SAAS,gBAAgBC,YAAoD;AAChF,QAAO;EACH,MAAM;EACN,GAAG;CACN;AACJ"}
|
package/dist/generators/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import { generateOpenAPISpec, spec_exports } from "../generators-
|
|
1
|
+
import "../schema-D3ybOrpr.js";
|
|
2
|
+
import { generateOpenAPISpec, spec_exports } from "../generators-JMALItMS.js";
|
|
3
3
|
|
|
4
4
|
export { generateOpenAPISpec, spec_exports as spec };
|