@typespec/openapi3 0.45.0-dev.7 → 0.45.0-dev.8

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.
@@ -1,6 +1,6 @@
1
- import { DecoratorContext, Program, Type } from "@typespec/compiler";
2
- export declare function $useRef(context: DecoratorContext, entity: Type, refUrl: string): void;
1
+ import { DecoratorContext, Model, ModelProperty, Program, Type, Union } from "@typespec/compiler";
2
+ export declare function $useRef(context: DecoratorContext, entity: Model | ModelProperty, refUrl: string): void;
3
3
  export declare function getRef(program: Program, entity: Type): string | undefined;
4
- export declare function $oneOf(context: DecoratorContext, entity: Type): void;
4
+ export declare function $oneOf(context: DecoratorContext, entity: Union): void;
5
5
  export declare function getOneOf(program: Program, entity: Type): boolean;
6
6
  //# sourceMappingURL=decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAA2B,MAAM,oBAAoB,CAAC;AAI9F,wBAAgB,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAMrF;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAEzE;AAGD,wBAAgB,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,QAK7D;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO,CAEhE"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIlG,wBAAgB,OAAO,CACrB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,KAAK,GAAG,aAAa,EAC7B,MAAM,EAAE,MAAM,GACb,IAAI,CAEN;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAEzE;AAGD,wBAAgB,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,QAE9D;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,OAAO,CAEhE"}
@@ -1,10 +1,6 @@
1
- import { validateDecoratorTarget } from "@typespec/compiler";
2
1
  import { createStateSymbol } from "./lib.js";
3
2
  const refTargetsKey = createStateSymbol("refs");
4
3
  export function $useRef(context, entity, refUrl) {
5
- if (!validateDecoratorTarget(context, entity, "@useRef", ["Model", "ModelProperty"])) {
6
- return;
7
- }
8
4
  context.program.stateMap(refTargetsKey).set(entity, refUrl);
9
5
  }
10
6
  export function getRef(program, entity) {
@@ -12,9 +8,6 @@ export function getRef(program, entity) {
12
8
  }
13
9
  const oneOfKey = createStateSymbol("oneOf");
14
10
  export function $oneOf(context, entity) {
15
- if (!validateDecoratorTarget(context, entity, "@oneOf", "Union")) {
16
- return;
17
- }
18
11
  context.program.stateMap(oneOfKey).set(entity, true);
19
12
  }
20
13
  export function getOneOf(program, entity) {
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAChD,MAAM,UAAU,OAAO,CAAC,OAAyB,EAAE,MAAY,EAAE,MAAc;IAC7E,IAAI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M,CAAC,OAAgB,EAAE,MAAY;IACnD,OAAO,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,UAAU,MAAM,CAAC,OAAyB,EAAE,MAAa;IAC7D,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,MAAY;IACrD,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import "../dist/src/index.js";
2
+
3
+ namespace OpenAPI;
4
+
5
+ using TypeSpec.Reflection;
6
+
7
+ /**
8
+ * Specify that `oneOf` should be used instead of `anyOf` for that union.
9
+ */
10
+ extern dec oneOf(target: Union);
11
+ /**
12
+ * Specify an external reference that should be used inside of emitting this type.
13
+ * @param ref External reference(e.g. "../../common.json#/components/schemas/Foo")
14
+ */
15
+ extern dec useRef(target: Model | ModelProperty, ref: string);
package/lib/main.tsp ADDED
@@ -0,0 +1 @@
1
+ import "./decorators.tsp";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/openapi3",
3
- "version": "0.45.0-dev.7",
3
+ "version": "0.45.0-dev.8",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding",
6
6
  "homepage": "https://microsoft.github.io/typespec",
@@ -18,6 +18,7 @@
18
18
  ],
19
19
  "type": "module",
20
20
  "main": "dist/src/index.js",
21
+ "tspMain": "lib/main.tsp",
21
22
  "exports": {
22
23
  ".": "./dist/src/index.js",
23
24
  "./testing": "./dist/src/testing/index.js"
@@ -32,7 +33,6 @@
32
33
  ]
33
34
  }
34
35
  },
35
- "tspMain": "dist/src/index.js",
36
36
  "engines": {
37
37
  "node": ">=16.0.0"
38
38
  },