@typespec/openapi 0.62.0-dev.2 → 0.62.0-dev.4
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/README.md +20 -0
- package/dist/generated-defs/TypeSpec.OpenAPI.d.ts +18 -0
- package/dist/generated-defs/TypeSpec.OpenAPI.d.ts.map +1 -1
- package/dist/src/decorators.d.ts +14 -1
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +49 -41
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/helpers.d.ts +28 -1
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/helpers.js +85 -2
- package/dist/src/helpers.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +34 -4
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +16 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/tsp-index.d.ts.map +1 -1
- package/dist/src/tsp-index.js +2 -1
- package/dist/src/tsp-index.js.map +1 -1
- package/lib/decorators.tsp +29 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ npm install @typespec/openapi
|
|
|
17
17
|
- [`@externalDocs`](#@externaldocs)
|
|
18
18
|
- [`@info`](#@info)
|
|
19
19
|
- [`@operationId`](#@operationid)
|
|
20
|
+
- [`@tagMetadata`](#@tagmetadata)
|
|
20
21
|
|
|
21
22
|
#### `@defaultResponse`
|
|
22
23
|
|
|
@@ -148,3 +149,22 @@ Specify the OpenAPI `operationId` property for this operation.
|
|
|
148
149
|
@operationId("download")
|
|
149
150
|
op read(): string;
|
|
150
151
|
```
|
|
152
|
+
|
|
153
|
+
#### `@tagMetadata`
|
|
154
|
+
|
|
155
|
+
Specify OpenAPI additional information.
|
|
156
|
+
|
|
157
|
+
```typespec
|
|
158
|
+
@TypeSpec.OpenAPI.tagMetadata(name: valueof string, tagMetadata?: valueof TypeSpec.OpenAPI.TagMetadata)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
##### Target
|
|
162
|
+
|
|
163
|
+
`Namespace`
|
|
164
|
+
|
|
165
|
+
##### Parameters
|
|
166
|
+
|
|
167
|
+
| Name | Type | Description |
|
|
168
|
+
| ----------- | ------------------------------------- | ---------------------- |
|
|
169
|
+
| name | `valueof string` | tag name |
|
|
170
|
+
| tagMetadata | [valueof `TagMetadata`](#tagmetadata) | Additional information |
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { DecoratorContext, Model, Namespace, Operation, Type } from "@typespec/compiler";
|
|
2
|
+
export interface TagMetadata {
|
|
3
|
+
readonly [key: string]: unknown;
|
|
4
|
+
readonly description?: string;
|
|
5
|
+
readonly externalDocs?: ExternalDocs;
|
|
6
|
+
}
|
|
7
|
+
export interface ExternalDocs {
|
|
8
|
+
readonly [key: string]: unknown;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
}
|
|
2
12
|
/**
|
|
3
13
|
* Specify the OpenAPI `operationId` property for this operation.
|
|
4
14
|
*
|
|
@@ -55,11 +65,19 @@ export type ExternalDocsDecorator = (context: DecoratorContext, target: Type, ur
|
|
|
55
65
|
* @param additionalInfo Additional information
|
|
56
66
|
*/
|
|
57
67
|
export type InfoDecorator = (context: DecoratorContext, target: Namespace, additionalInfo: Type) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Specify OpenAPI additional information.
|
|
70
|
+
*
|
|
71
|
+
* @param name tag name
|
|
72
|
+
* @param tagMetadata Additional information
|
|
73
|
+
*/
|
|
74
|
+
export type TagMetadataDecorator = (context: DecoratorContext, target: Namespace, name: string, tagMetadata: TagMetadata) => void;
|
|
58
75
|
export type TypeSpecOpenAPIDecorators = {
|
|
59
76
|
operationId: OperationIdDecorator;
|
|
60
77
|
extension: ExtensionDecorator;
|
|
61
78
|
defaultResponse: DefaultResponseDecorator;
|
|
62
79
|
externalDocs: ExternalDocsDecorator;
|
|
63
80
|
info: InfoDecorator;
|
|
81
|
+
tagMetadata: TagMetadataDecorator;
|
|
64
82
|
};
|
|
65
83
|
//# sourceMappingURL=TypeSpec.OpenAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.OpenAPI.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.OpenAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE9F;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,KAChB,IAAI,CAAC;AAEV;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,IAAI,KACR,IAAI,CAAC;AAEV;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;AAE1F;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,KACjB,IAAI,CAAC;AAEV;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,IAAI,KACjB,IAAI,CAAC;AAEV,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,oBAAoB,CAAC;IAClC,SAAS,EAA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E,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,KACjB,IAAI,CAAC;AAEV;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,IAAI,KACjB,IAAI,CAAC;AAEV;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,KACrB,IAAI,CAAC;AAEV,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,oBAAoB,CAAC;IAClC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,eAAe,EAAE,wBAAwB,CAAC;IAC1C,YAAY,EAAE,qBAAqB,CAAC;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,oBAAoB,CAAC;CACnC,CAAC"}
|
package/dist/src/decorators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Namespace, Operation, Program, Type } from "@typespec/compiler";
|
|
2
|
-
import { DefaultResponseDecorator, ExtensionDecorator, ExternalDocsDecorator, InfoDecorator, OperationIdDecorator } from "../generated-defs/TypeSpec.OpenAPI.js";
|
|
2
|
+
import { DefaultResponseDecorator, ExtensionDecorator, ExternalDocsDecorator, InfoDecorator, OperationIdDecorator, TagMetadata, TagMetadataDecorator } from "../generated-defs/TypeSpec.OpenAPI.js";
|
|
3
3
|
import { AdditionalInfo, ExtensionKey, ExternalDocs } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Set a specific operation ID.
|
|
@@ -66,4 +66,17 @@ export declare const $info: InfoDecorator;
|
|
|
66
66
|
export declare function getInfo(program: Program, entity: Namespace): AdditionalInfo | undefined;
|
|
67
67
|
/** Resolve the info entry by merging data specified with `@service`, `@summary` and `@info`. */
|
|
68
68
|
export declare function resolveInfo(program: Program, entity: Namespace): AdditionalInfo | undefined;
|
|
69
|
+
/** Get TagsMetadata set with `@tagMetadata` decorator */
|
|
70
|
+
declare const getTagsMetadata: (program: Program, type: Type) => {
|
|
71
|
+
[name: string]: TagMetadata;
|
|
72
|
+
} | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Decorator to add metadata to a tag associated with a namespace.
|
|
75
|
+
* @param context - The decorator context.
|
|
76
|
+
* @param entity - The namespace entity to associate the tag with.
|
|
77
|
+
* @param name - The name of the tag.
|
|
78
|
+
* @param tagMetadata - Optional metadata for the tag.
|
|
79
|
+
*/
|
|
80
|
+
export declare const tagMetadataDecorator: TagMetadataDecorator;
|
|
81
|
+
export { getTagsMetadata };
|
|
69
82
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,SAAS,EACT,SAAS,EACT,OAAO,EACP,IAAI,EAGL,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,oBAAoB,EACrB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGxE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,oBAM1B,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEtF;AAID,uCAAuC;AACvC,eAAO,MAAM,UAAU,EAAE,kBAmBxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,O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
1
|
-
import {
|
|
1
|
+
import { $service, getDoc, getService, getSummary, typespecTypeToJson, } from "@typespec/compiler";
|
|
2
|
+
import { unsafe_useStateMap } from "@typespec/compiler/experimental";
|
|
2
3
|
import { setStatusCode } from "@typespec/http";
|
|
3
|
-
import {
|
|
4
|
+
import { isOpenAPIExtensionKey, validateAdditionalInfoModel, validateIsUri } from "./helpers.js";
|
|
5
|
+
import { createStateSymbol, OpenAPIKeys, reportDiagnostic } from "./lib.js";
|
|
4
6
|
const operationIdsKey = createStateSymbol("operationIds");
|
|
5
7
|
/**
|
|
6
8
|
* Set a specific operation ID.
|
|
@@ -63,9 +65,6 @@ export function setExtension(program, entity, extensionName, data) {
|
|
|
63
65
|
export function getExtensions(program, entity) {
|
|
64
66
|
return program.stateMap(openApiExtensionKey).get(entity) ?? new Map();
|
|
65
67
|
}
|
|
66
|
-
function isOpenAPIExtensionKey(key) {
|
|
67
|
-
return key.startsWith("x-");
|
|
68
|
-
}
|
|
69
68
|
/**
|
|
70
69
|
* The @defaultResponse decorator can be applied to a model. When that model is used
|
|
71
70
|
* as the return type of an operation, this return type will be the default response.
|
|
@@ -116,9 +115,13 @@ export const $info = (context, entity, model) => {
|
|
|
116
115
|
if (data === undefined) {
|
|
117
116
|
return;
|
|
118
117
|
}
|
|
119
|
-
|
|
118
|
+
// Validate the AdditionalInfo model
|
|
119
|
+
if (!validateAdditionalInfoModel(context.program, context.getArgumentTarget(0), data, "TypeSpec.OpenAPI.AdditionalInfo")) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Validate termsOfService
|
|
120
123
|
if (data.termsOfService) {
|
|
121
|
-
if (!validateIsUri(context, data.termsOfService, "TermsOfService")) {
|
|
124
|
+
if (!validateIsUri(context.program, context.getArgumentTarget(0), data.termsOfService, "TermsOfService")) {
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
124
127
|
}
|
|
@@ -148,46 +151,51 @@ export function resolveInfo(program, entity) {
|
|
|
148
151
|
function omitUndefined(data) {
|
|
149
152
|
return Object.fromEntries(Object.entries(data).filter(([k, v]) => v !== undefined));
|
|
150
153
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
/** Get TagsMetadata set with `@tagMetadata` decorator */
|
|
155
|
+
const [getTagsMetadata, setTagsMetadata] = unsafe_useStateMap(OpenAPIKeys.tagsMetadata);
|
|
156
|
+
/**
|
|
157
|
+
* Decorator to add metadata to a tag associated with a namespace.
|
|
158
|
+
* @param context - The decorator context.
|
|
159
|
+
* @param entity - The namespace entity to associate the tag with.
|
|
160
|
+
* @param name - The name of the tag.
|
|
161
|
+
* @param tagMetadata - Optional metadata for the tag.
|
|
162
|
+
*/
|
|
163
|
+
export const tagMetadataDecorator = (context, entity, name, tagMetadata) => {
|
|
164
|
+
// Check if the namespace is a service namespace
|
|
165
|
+
if (!entity.decorators.some((decorator) => decorator.decorator === $service)) {
|
|
166
|
+
reportDiagnostic(context.program, {
|
|
167
|
+
code: "tag-metadata-target-service",
|
|
168
|
+
format: {
|
|
169
|
+
namespace: entity.name,
|
|
170
|
+
},
|
|
171
|
+
target: context.getArgumentTarget(0),
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
155
174
|
}
|
|
156
|
-
|
|
175
|
+
// Retrieve existing tags metadata or initialize an empty object
|
|
176
|
+
const tags = getTagsMetadata(context.program, entity) ?? {};
|
|
177
|
+
// Check for duplicate tag names
|
|
178
|
+
if (tags[name]) {
|
|
157
179
|
reportDiagnostic(context.program, {
|
|
158
|
-
code: "
|
|
180
|
+
code: "duplicate-tag",
|
|
181
|
+
format: { tagName: name },
|
|
159
182
|
target: context.getArgumentTarget(0),
|
|
160
|
-
format: { property: propertyName, value: url },
|
|
161
183
|
});
|
|
162
|
-
return
|
|
184
|
+
return;
|
|
163
185
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (typeof typespecType === "object" && propertyModel) {
|
|
168
|
-
const diagnostics = checkNoAdditionalProperties(typespecType, context.getArgumentTarget(0), propertyModel);
|
|
169
|
-
context.program.reportDiagnostics(diagnostics);
|
|
186
|
+
// Validate the additionalInfo model
|
|
187
|
+
if (!validateAdditionalInfoModel(context.program, context.getArgumentTarget(0), tagMetadata, "TypeSpec.OpenAPI.TagMetadata")) {
|
|
188
|
+
return;
|
|
170
189
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (const [name, type] of typespecType.properties.entries()) {
|
|
176
|
-
const sourceProperty = getProperty(source, name);
|
|
177
|
-
if (sourceProperty) {
|
|
178
|
-
if (sourceProperty.type.kind === "Model") {
|
|
179
|
-
const nestedDiagnostics = checkNoAdditionalProperties(type.type, target, sourceProperty.type);
|
|
180
|
-
diagnostics.push(...nestedDiagnostics);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else if (!isOpenAPIExtensionKey(name)) {
|
|
184
|
-
diagnostics.push(createDiagnostic({
|
|
185
|
-
code: "invalid-extension-key",
|
|
186
|
-
format: { value: name },
|
|
187
|
-
target,
|
|
188
|
-
}));
|
|
190
|
+
// Validate the externalDocs.url property
|
|
191
|
+
if (tagMetadata.externalDocs?.url) {
|
|
192
|
+
if (!validateIsUri(context.program, context.getArgumentTarget(0), tagMetadata.externalDocs.url, "externalDocs.url")) {
|
|
193
|
+
return;
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
// Update the tags metadata with the new tag
|
|
197
|
+
tags[name] = tagMetadata;
|
|
198
|
+
setTagsMetadata(context.program, entity, tags);
|
|
199
|
+
};
|
|
200
|
+
export { getTagsMetadata };
|
|
193
201
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts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MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YACzB,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAE;SACtC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,oCAAoC;IACpC,IACE,CAAC,2BAA2B,CAC1B,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAE,EAC7B,WAAW,EACX,8BAA8B,CAC/B,EACD,CAAC;QACD,OAAO;IACT,CAAC;IAED,yCAAyC;IACzC,IAAI,WAAW,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC;QAClC,IACE,CAAC,aAAa,CACZ,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAE,EAC7B,WAAW,CAAC,YAAY,CAAC,GAAG,EAC5B,kBAAkB,CACnB,EACD,CAAC;YACD,OAAO;QACT,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACzB,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ModelProperty, Operation, Program, Type, TypeNameOptions } from "@typespec/compiler";
|
|
1
|
+
import { DiagnosticTarget, ModelProperty, Operation, Program, Type, TypeNameOptions } from "@typespec/compiler";
|
|
2
|
+
import { ExtensionKey } from "./types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Determines whether a type will be inlined in OpenAPI rather than defined
|
|
4
5
|
* as a schema and referenced.
|
|
@@ -54,4 +55,30 @@ export declare function resolveOperationId(program: Program, operation: Operatio
|
|
|
54
55
|
* designate a read-only property.
|
|
55
56
|
*/
|
|
56
57
|
export declare function isReadonlyProperty(program: Program, property: ModelProperty): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Determines if a OpenAPIExtensionKey is start with `x-`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isOpenAPIExtensionKey(key: string): key is ExtensionKey;
|
|
62
|
+
/**
|
|
63
|
+
* Validate that the given string is a valid URL.
|
|
64
|
+
* @param program Program
|
|
65
|
+
* @param target Diagnostic target for any diagnostics that are reported
|
|
66
|
+
* @param url The URL to validate
|
|
67
|
+
* @param propertyName The name of the property that the URL is associated with
|
|
68
|
+
* @returns true if the URL is valid, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
export declare function validateIsUri(program: Program, target: DiagnosticTarget, url: string, propertyName: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Validate the AdditionalInfo model against a reference.
|
|
73
|
+
*
|
|
74
|
+
* This function checks that the properties of the given AdditionalInfo object
|
|
75
|
+
* are a subset of the properties defined in the AdditionalInfo model.
|
|
76
|
+
*
|
|
77
|
+
* @param program - The TypeSpec Program instance
|
|
78
|
+
* @param target - Diagnostic target for reporting any diagnostics
|
|
79
|
+
* @param jsonObject - The AdditionalInfo object to validate
|
|
80
|
+
* @param reference - The reference string to resolve the model
|
|
81
|
+
* @returns true if the AdditionalInfo object is valid, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
export declare function validateAdditionalInfoModel(program: Program, target: DiagnosticTarget, jsonObject: object, reference: string): boolean;
|
|
57
84
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAShB,aAAa,EACb,SAAS,EACT,OAAO,EACP,IAAI,EACJ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;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AAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAiBT"}
|
package/dist/src/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getFriendlyName, getTypeName, getVisibility, isGlobalNamespace, isService, isTemplateInstance, } from "@typespec/compiler";
|
|
1
|
+
import { getFriendlyName, getProperty, getTypeName, getVisibility, isGlobalNamespace, isService, isTemplateInstance, } from "@typespec/compiler";
|
|
2
2
|
import { getOperationId } from "./decorators.js";
|
|
3
|
-
import { reportDiagnostic } from "./lib.js";
|
|
3
|
+
import { createDiagnostic, reportDiagnostic } from "./lib.js";
|
|
4
4
|
/**
|
|
5
5
|
* Determines whether a type will be inlined in OpenAPI rather than defined
|
|
6
6
|
* as a schema and referenced.
|
|
@@ -122,4 +122,87 @@ export function isReadonlyProperty(program, property) {
|
|
|
122
122
|
// readonly: true, but using separate schemas.
|
|
123
123
|
return visibility?.length === 1 && visibility[0] === "read";
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Determines if a OpenAPIExtensionKey is start with `x-`.
|
|
127
|
+
*/
|
|
128
|
+
export function isOpenAPIExtensionKey(key) {
|
|
129
|
+
return key.startsWith("x-");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Validate that the given string is a valid URL.
|
|
133
|
+
* @param program Program
|
|
134
|
+
* @param target Diagnostic target for any diagnostics that are reported
|
|
135
|
+
* @param url The URL to validate
|
|
136
|
+
* @param propertyName The name of the property that the URL is associated with
|
|
137
|
+
* @returns true if the URL is valid, false otherwise
|
|
138
|
+
*/
|
|
139
|
+
export function validateIsUri(program, target, url, propertyName) {
|
|
140
|
+
try {
|
|
141
|
+
// Attempt to create a URL object from the given string. If
|
|
142
|
+
// successful, the URL is valid.
|
|
143
|
+
new URL(url);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// If the URL is invalid, report a diagnostic with the given
|
|
148
|
+
// target, property name and value.
|
|
149
|
+
reportDiagnostic(program, {
|
|
150
|
+
code: "not-url",
|
|
151
|
+
target: target,
|
|
152
|
+
format: { property: propertyName, value: url },
|
|
153
|
+
});
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Validate the AdditionalInfo model against a reference.
|
|
159
|
+
*
|
|
160
|
+
* This function checks that the properties of the given AdditionalInfo object
|
|
161
|
+
* are a subset of the properties defined in the AdditionalInfo model.
|
|
162
|
+
*
|
|
163
|
+
* @param program - The TypeSpec Program instance
|
|
164
|
+
* @param target - Diagnostic target for reporting any diagnostics
|
|
165
|
+
* @param jsonObject - The AdditionalInfo object to validate
|
|
166
|
+
* @param reference - The reference string to resolve the model
|
|
167
|
+
* @returns true if the AdditionalInfo object is valid, false otherwise
|
|
168
|
+
*/
|
|
169
|
+
export function validateAdditionalInfoModel(program, target, jsonObject, reference) {
|
|
170
|
+
// Resolve the reference to get the corresponding model
|
|
171
|
+
const propertyModel = program.resolveTypeReference(reference)[0];
|
|
172
|
+
// Check if jsonObject and propertyModel are defined
|
|
173
|
+
if (jsonObject && propertyModel) {
|
|
174
|
+
// Validate that the properties of typespecType do not exceed those in propertyModel
|
|
175
|
+
const diagnostics = checkNoAdditionalProperties(jsonObject, target, propertyModel);
|
|
176
|
+
program.reportDiagnostics(diagnostics);
|
|
177
|
+
// Return false if any diagnostics were reported, indicating a validation failure
|
|
178
|
+
if (diagnostics.length > 0) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Return true if validation is successful
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Check Additional Properties
|
|
187
|
+
*/
|
|
188
|
+
function checkNoAdditionalProperties(jsonObject, target, source) {
|
|
189
|
+
const diagnostics = [];
|
|
190
|
+
for (const name of Object.keys(jsonObject)) {
|
|
191
|
+
const sourceProperty = getProperty(source, name);
|
|
192
|
+
if (sourceProperty) {
|
|
193
|
+
if (sourceProperty.type.kind === "Model") {
|
|
194
|
+
const nestedDiagnostics = checkNoAdditionalProperties(jsonObject[name], target, sourceProperty.type);
|
|
195
|
+
diagnostics.push(...nestedDiagnostics);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (!isOpenAPIExtensionKey(name)) {
|
|
199
|
+
diagnostics.push(createDiagnostic({
|
|
200
|
+
code: "invalid-extension-key",
|
|
201
|
+
format: { value: name },
|
|
202
|
+
target,
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return diagnostics;
|
|
207
|
+
}
|
|
125
208
|
//# sourceMappingURL=helpers.js.map
|
package/dist/src/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,kBAAkB,GAOnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAU;IACvD,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,I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AI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACzC,MAAM,iBAAiB,GAAG,2BAA2B,CACnD,UAAU,CAAC,IAAI,CAAC,EAChB,MAAM,EACN,cAAc,CAAC,IAAI,CACpB,CAAC;gBACF,WAAW,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,WAAW,CAAC,IAAI,CACd,gBAAgB,CAAC;gBACf,IAAI,EAAE,uBAAuB;gBAC7B,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gBACvB,MAAM;aACP,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { DefaultResponseDecorator, ExtensionDecorator, ExternalDocsDecorator, InfoDecorator, } from "../generated-defs/TypeSpec.OpenAPI.js";
|
|
2
|
-
export { $defaultResponse, $extension, $externalDocs, $info, $operationId, getExtensions, getExternalDocs, getInfo, getOperationId, isDefaultResponse, resolveInfo, setExtension, setInfo, } from "./decorators.js";
|
|
2
|
+
export { $defaultResponse, $extension, $externalDocs, $info, $operationId, getExtensions, getExternalDocs, getInfo, getOperationId, getTagsMetadata, isDefaultResponse, resolveInfo, setExtension, setInfo, } from "./decorators.js";
|
|
3
3
|
export { checkDuplicateTypeName, getOpenAPITypeName, getParameterKey, isReadonlyProperty, resolveOperationId, shouldInline, } from "./helpers.js";
|
|
4
4
|
export { AdditionalInfo, Contact, ExtensionKey, ExternalDocs, License } from "./types.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,GACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,GACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,OAAO,EACP,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $defaultResponse, $extension, $externalDocs, $info, $operationId, getExtensions, getExternalDocs, getInfo, getOperationId, isDefaultResponse, resolveInfo, setExtension, setInfo, } from "./decorators.js";
|
|
1
|
+
export { $defaultResponse, $extension, $externalDocs, $info, $operationId, getExtensions, getExternalDocs, getInfo, getOperationId, getTagsMetadata, isDefaultResponse, resolveInfo, setExtension, setInfo, } from "./decorators.js";
|
|
2
2
|
export { checkDuplicateTypeName, getOpenAPITypeName, getParameterKey, isReadonlyProperty, resolveOperationId, shouldInline, } from "./helpers.js";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export { $decorators } from "./tsp-index.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,OAAO,EACP,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/src/lib.d.ts
CHANGED
|
@@ -9,8 +9,14 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
9
9
|
"not-url": {
|
|
10
10
|
readonly default: import("@typespec/compiler").CallableMessage<["property", "value"]>;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
"duplicate-tag": {
|
|
13
|
+
readonly default: import("@typespec/compiler").CallableMessage<["tagName"]>;
|
|
14
|
+
};
|
|
15
|
+
"tag-metadata-target-service": {
|
|
16
|
+
readonly default: import("@typespec/compiler").CallableMessage<["namespace"]>;
|
|
17
|
+
};
|
|
18
|
+
}, Record<string, any>, "tagsMetadata">;
|
|
19
|
+
export declare const createDiagnostic: <C extends "invalid-extension-key" | "duplicate-type-name" | "not-url" | "duplicate-tag" | "tag-metadata-target-service", M extends keyof {
|
|
14
20
|
"invalid-extension-key": {
|
|
15
21
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
16
22
|
};
|
|
@@ -21,6 +27,12 @@ export declare const createDiagnostic: <C extends "invalid-extension-key" | "dup
|
|
|
21
27
|
"not-url": {
|
|
22
28
|
readonly default: import("@typespec/compiler").CallableMessage<["property", "value"]>;
|
|
23
29
|
};
|
|
30
|
+
"duplicate-tag": {
|
|
31
|
+
readonly default: import("@typespec/compiler").CallableMessage<["tagName"]>;
|
|
32
|
+
};
|
|
33
|
+
"tag-metadata-target-service": {
|
|
34
|
+
readonly default: import("@typespec/compiler").CallableMessage<["namespace"]>;
|
|
35
|
+
};
|
|
24
36
|
}[C]>(diag: import("@typespec/compiler").DiagnosticReport<{
|
|
25
37
|
"invalid-extension-key": {
|
|
26
38
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
@@ -32,7 +44,13 @@ export declare const createDiagnostic: <C extends "invalid-extension-key" | "dup
|
|
|
32
44
|
"not-url": {
|
|
33
45
|
readonly default: import("@typespec/compiler").CallableMessage<["property", "value"]>;
|
|
34
46
|
};
|
|
35
|
-
|
|
47
|
+
"duplicate-tag": {
|
|
48
|
+
readonly default: import("@typespec/compiler").CallableMessage<["tagName"]>;
|
|
49
|
+
};
|
|
50
|
+
"tag-metadata-target-service": {
|
|
51
|
+
readonly default: import("@typespec/compiler").CallableMessage<["namespace"]>;
|
|
52
|
+
};
|
|
53
|
+
}, C, M>) => import("@typespec/compiler").Diagnostic, reportDiagnostic: <C extends "invalid-extension-key" | "duplicate-type-name" | "not-url" | "duplicate-tag" | "tag-metadata-target-service", M extends keyof {
|
|
36
54
|
"invalid-extension-key": {
|
|
37
55
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
38
56
|
};
|
|
@@ -43,6 +61,12 @@ export declare const createDiagnostic: <C extends "invalid-extension-key" | "dup
|
|
|
43
61
|
"not-url": {
|
|
44
62
|
readonly default: import("@typespec/compiler").CallableMessage<["property", "value"]>;
|
|
45
63
|
};
|
|
64
|
+
"duplicate-tag": {
|
|
65
|
+
readonly default: import("@typespec/compiler").CallableMessage<["tagName"]>;
|
|
66
|
+
};
|
|
67
|
+
"tag-metadata-target-service": {
|
|
68
|
+
readonly default: import("@typespec/compiler").CallableMessage<["namespace"]>;
|
|
69
|
+
};
|
|
46
70
|
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
47
71
|
"invalid-extension-key": {
|
|
48
72
|
readonly default: import("@typespec/compiler").CallableMessage<["value"]>;
|
|
@@ -54,5 +78,11 @@ export declare const createDiagnostic: <C extends "invalid-extension-key" | "dup
|
|
|
54
78
|
"not-url": {
|
|
55
79
|
readonly default: import("@typespec/compiler").CallableMessage<["property", "value"]>;
|
|
56
80
|
};
|
|
57
|
-
|
|
81
|
+
"duplicate-tag": {
|
|
82
|
+
readonly default: import("@typespec/compiler").CallableMessage<["tagName"]>;
|
|
83
|
+
};
|
|
84
|
+
"tag-metadata-target-service": {
|
|
85
|
+
readonly default: import("@typespec/compiler").CallableMessage<["namespace"]>;
|
|
86
|
+
};
|
|
87
|
+
}, C, M>) => void, createStateSymbol: (name: string) => symbol, OpenAPIKeys: Record<"tagsMetadata", symbol>;
|
|
58
88
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/src/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;uCAsCf,CAAC;AAEH,eAAO,MACL,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAChB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAChB,iBAAiB,4BACN,WAAW,gCAChB,CAAC"}
|
package/dist/src/lib.js
CHANGED
|
@@ -21,7 +21,22 @@ export const $lib = createTypeSpecLibrary({
|
|
|
21
21
|
default: paramMessage `${"property"}: ${"value"} is not a valid URL.`,
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
|
+
"duplicate-tag": {
|
|
25
|
+
severity: "error",
|
|
26
|
+
messages: {
|
|
27
|
+
default: paramMessage `"Metadata for tag '${"tagName"}' was specified twice."`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
"tag-metadata-target-service": {
|
|
31
|
+
severity: "error",
|
|
32
|
+
messages: {
|
|
33
|
+
default: paramMessage `@tagMetadata must be used on the service namespace. Did you mean to annotate '${"namespace"}' with '@service'?`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
state: {
|
|
38
|
+
tagsMetadata: { description: "State for the @tagMetadata decorator." },
|
|
24
39
|
},
|
|
25
40
|
});
|
|
26
|
-
export const { createDiagnostic, reportDiagnostic, createStateSymbol } = $lib;
|
|
41
|
+
export const { createDiagnostic, reportDiagnostic, createStateSymbol, stateKeys: OpenAPIKeys, } = $lib;
|
|
27
42
|
//# sourceMappingURL=lib.js.map
|
package/dist/src/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACxC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE;QACX,uBAAuB,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,mDAAmD,OAAO,GAAG;aACnF;SACF;QACD,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,yBAAyB,OAAO,4FAA4F;gBACjJ,SAAS,EAAE,YAAY,CAAA,6BAA6B,OAAO,4FAA4F;aACxJ;SACF;QACD,SAAS,EAAE;YACT,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,GAAG,UAAU,KAAK,OAAO,sBAAsB;aACrE;SACF;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACxC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE;QACX,uBAAuB,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,mDAAmD,OAAO,GAAG;aACnF;SACF;QACD,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,yBAAyB,OAAO,4FAA4F;gBACjJ,SAAS,EAAE,YAAY,CAAA,6BAA6B,OAAO,4FAA4F;aACxJ;SACF;QACD,SAAS,EAAE;YACT,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,GAAG,UAAU,KAAK,OAAO,sBAAsB;aACrE;SACF;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,sBAAsB,SAAS,yBAAyB;aAC9E;SACF;QACD,6BAA6B,EAAE;YAC7B,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,iFAAiF,WAAW,qBAAqB;aACvI;SACF;KACF;IACD,KAAK,EAAE;QACL,YAAY,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE;KACvE;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EAAE,WAAW,GACvB,GAAG,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsp-index.d.ts","sourceRoot":"","sources":["../../src/tsp-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tsp-index.d.ts","sourceRoot":"","sources":["../../src/tsp-index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/src/tsp-index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $defaultResponse, $extension, $externalDocs, $info, $operationId } from "./decorators.js";
|
|
1
|
+
import { $defaultResponse, $extension, $externalDocs, $info, $operationId, tagMetadataDecorator, } from "./decorators.js";
|
|
2
2
|
export { $lib } from "./lib.js";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export const $decorators = {
|
|
@@ -8,6 +8,7 @@ export const $decorators = {
|
|
|
8
8
|
externalDocs: $externalDocs,
|
|
9
9
|
info: $info,
|
|
10
10
|
operationId: $operationId,
|
|
11
|
+
tagMetadata: tagMetadataDecorator,
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=tsp-index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsp-index.js","sourceRoot":"","sources":["../../src/tsp-index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"tsp-index.js","sourceRoot":"","sources":["../../src/tsp-index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,kBAAkB,EAAE;QAClB,eAAe,EAAE,gBAAgB;QACjC,SAAS,EAAE,UAAU;QACrB,YAAY,EAAE,aAAa;QAC3B,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,YAAY;QACzB,WAAW,EAAE,oBAAoB;KACE;CACtC,CAAC"}
|
package/lib/decorators.tsp
CHANGED
|
@@ -109,3 +109,32 @@ model License {
|
|
|
109
109
|
* @param additionalInfo Additional information
|
|
110
110
|
*/
|
|
111
111
|
extern dec info(target: Namespace, additionalInfo: AdditionalInfo);
|
|
112
|
+
|
|
113
|
+
/** Metadata to a single tag that is used by operations. */
|
|
114
|
+
model TagMetadata {
|
|
115
|
+
/** A description of the API. */
|
|
116
|
+
description?: string;
|
|
117
|
+
|
|
118
|
+
/** An external Docs information of the API. */
|
|
119
|
+
externalDocs?: ExternalDocs;
|
|
120
|
+
|
|
121
|
+
...Record<unknown>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** External Docs information. */
|
|
125
|
+
model ExternalDocs {
|
|
126
|
+
/** Documentation url */
|
|
127
|
+
url: string;
|
|
128
|
+
|
|
129
|
+
/** Optional description */
|
|
130
|
+
description?: string;
|
|
131
|
+
|
|
132
|
+
...Record<unknown>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Specify OpenAPI additional information.
|
|
137
|
+
* @param name tag name
|
|
138
|
+
* @param tagMetadata Additional information
|
|
139
|
+
*/
|
|
140
|
+
extern dec tagMetadata(target: Namespace, name: valueof string, tagMetadata: valueof TagMetadata);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/openapi",
|
|
3
|
-
"version": "0.62.0-dev.
|
|
3
|
+
"version": "0.62.0-dev.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library providing OpenAPI concepts",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"test:ci": "vitest run --coverage --reporter=junit --reporter=default",
|
|
70
70
|
"lint": "eslint . --max-warnings=0",
|
|
71
71
|
"lint:fix": "eslint . --fix",
|
|
72
|
-
"regen-docs": "tspd doc . --enable-experimental --output-dir ../../docs/libraries/openapi/reference",
|
|
72
|
+
"regen-docs": "tspd doc . --enable-experimental --output-dir ../../website/src/content/docs/docs/libraries/openapi/reference",
|
|
73
73
|
"api-extractor": "api-extractor run --local --verbose"
|
|
74
74
|
}
|
|
75
75
|
}
|