@skmtc/core 0.28.2 → 0.28.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.
Files changed (37) hide show
  1. package/esm/oas/example/Example.d.ts +2 -2
  2. package/esm/oas/example/Example.d.ts.map +1 -1
  3. package/esm/oas/example/Example.js +4 -1
  4. package/esm/parse/v3-0/example/toExamplesV3.d.ts +10 -5
  5. package/esm/parse/v3-0/example/toExamplesV3.d.ts.map +1 -1
  6. package/esm/parse/v3-0/example/toExamplesV3.js +27 -18
  7. package/esm/parse/v3-0/header/toHeadersV3.d.ts +2 -0
  8. package/esm/parse/v3-0/header/toHeadersV3.d.ts.map +1 -1
  9. package/esm/parse/v3-0/header/toHeadersV3.js +3 -3
  10. package/esm/parse/v3-1/example/toExamplesV3.d.ts +10 -5
  11. package/esm/parse/v3-1/example/toExamplesV3.d.ts.map +1 -1
  12. package/esm/parse/v3-1/example/toExamplesV3.js +27 -18
  13. package/esm/parse/v3-1/header/toHeadersV3.d.ts +2 -0
  14. package/esm/parse/v3-1/header/toHeadersV3.d.ts.map +1 -1
  15. package/esm/parse/v3-1/header/toHeadersV3.js +3 -3
  16. package/esm/types/DenoJson.d.ts +6 -0
  17. package/esm/types/DenoJson.d.ts.map +1 -1
  18. package/esm/types/DenoJson.js +5 -1
  19. package/package.json +1 -1
  20. package/script/oas/example/Example.d.ts +2 -2
  21. package/script/oas/example/Example.d.ts.map +1 -1
  22. package/script/oas/example/Example.js +4 -1
  23. package/script/parse/v3-0/example/toExamplesV3.d.ts +10 -5
  24. package/script/parse/v3-0/example/toExamplesV3.d.ts.map +1 -1
  25. package/script/parse/v3-0/example/toExamplesV3.js +27 -18
  26. package/script/parse/v3-0/header/toHeadersV3.d.ts +2 -0
  27. package/script/parse/v3-0/header/toHeadersV3.d.ts.map +1 -1
  28. package/script/parse/v3-0/header/toHeadersV3.js +3 -3
  29. package/script/parse/v3-1/example/toExamplesV3.d.ts +10 -5
  30. package/script/parse/v3-1/example/toExamplesV3.d.ts.map +1 -1
  31. package/script/parse/v3-1/example/toExamplesV3.js +27 -18
  32. package/script/parse/v3-1/header/toHeadersV3.d.ts +2 -0
  33. package/script/parse/v3-1/header/toHeadersV3.d.ts.map +1 -1
  34. package/script/parse/v3-1/header/toHeadersV3.js +3 -3
  35. package/script/types/DenoJson.d.ts +6 -0
  36. package/script/types/DenoJson.d.ts.map +1 -1
  37. package/script/types/DenoJson.js +5 -1
@@ -9,8 +9,8 @@ export type ExampleFields = {
9
9
  summary?: string;
10
10
  /** Longer description of the example */
11
11
  description?: string;
12
- /** The example value */
13
- value: unknown;
12
+ /** The example value — absent when the example is given as an `externalValue` */
13
+ value?: unknown;
14
14
  /** The external value of the example */
15
15
  externalValue?: string;
16
16
  /** Custom extension fields (x-* properties) */
@@ -1 +1 @@
1
- {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,UAAU;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;IAC9B,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,M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M,EAAE,OAAO,CAAC,CAAA;gBAE7B,MAAM,EAAE,aAAa;IAQjC,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAUrE"}
@@ -59,7 +59,10 @@ export class OasExample {
59
59
  return {
60
60
  summary: this.summary,
61
61
  description: this.description,
62
- value: this.value
62
+ value: this.value,
63
+ // Without this an `externalValue`-only example round-trips to an Example
64
+ // Object holding neither an inline value nor a pointer to one.
65
+ externalValue: this.externalValue
63
66
  };
64
67
  }
65
68
  }
@@ -4,7 +4,12 @@ import { OasExample } from '../../../oas/example/Example.js';
4
4
  import type { OasRef } from '../../../oas/ref/Ref.js';
5
5
  import type { StackTrail } from '../../../context/StackTrail.js';
6
6
  export type ToExampleSimpleV3Args = {
7
- example: OpenAPIV3.ExampleObject;
7
+ /**
8
+ * The example value itself. The singular `example` field of a media type,
9
+ * parameter or header is a LITERAL value — not an Example Object — so it
10
+ * carries no `summary`, `description` or `externalValue` to read.
11
+ */
12
+ example: unknown;
8
13
  /** The stack trail for tracing */
9
14
  stackTrail: StackTrail;
10
15
  /** Parse context for tracing and error handling */
@@ -13,8 +18,8 @@ export type ToExampleSimpleV3Args = {
13
18
  /**
14
19
  * Creates a simple OAS example from a value.
15
20
  *
16
- * Converts a raw example value into an OasExample object with basic
17
- * fields. Used for simple example scenarios where only the value matters.
21
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
22
+ * `example` field, where only the value exists.
18
23
  *
19
24
  * @param args - Arguments containing the example value
20
25
  * @returns OasExample object with the provided value
@@ -27,8 +32,8 @@ export declare const toExampleSimpleV3: ({ example }: ToExampleSimpleV3Args) =>
27
32
  * with context for tracing and error handling.
28
33
  */
29
34
  export type ToExamplesV3Args = {
30
- /** Single example object (OpenAPI v3 format) */
31
- example: OpenAPIV3.ExampleObject | undefined;
35
+ /** The singular `example` field — a literal value, not an Example Object */
36
+ example: unknown;
32
37
  /** Collection of named examples (OpenAPI v3 format) */
33
38
  examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
34
39
  /** Key name for the example context */
@@ -1 +1 @@
1
- {"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-0/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC,aAAa,CAAA;IAChC,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAE/B,qBAAqB,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CASvD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,O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EAAE,OAAO,CAAA;IAChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,wDAM1B,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SAiDtE,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAyBjD,CAAA"}
@@ -5,19 +5,14 @@ import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecif
5
5
  /**
6
6
  * Creates a simple OAS example from a value.
7
7
  *
8
- * Converts a raw example value into an OasExample object with basic
9
- * fields. Used for simple example scenarios where only the value matters.
8
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
9
+ * `example` field, where only the value exists.
10
10
  *
11
11
  * @param args - Arguments containing the example value
12
12
  * @returns OasExample object with the provided value
13
13
  */
14
14
  export const toExampleSimpleV3 = ({ example }) => {
15
- const fields = {
16
- value: example.value,
17
- summary: example.summary,
18
- description: example.description,
19
- externalValue: example.externalValue
20
- };
15
+ const fields = { value: example };
21
16
  return new OasExample(fields);
22
17
  };
23
18
  /**
@@ -31,31 +26,41 @@ export const toExampleSimpleV3 = ({ example }) => {
31
26
  * @returns Record of processed examples, or undefined if no examples
32
27
  */
33
28
  export const toExamplesV3 = ({ example, examples, exampleKey, stackTrail, context }) => {
34
- if (example && examples) {
29
+ // An empty map is declared but carries nothing, so it cannot be the richer
30
+ // field — letting it win would discard the singular in favour of no examples
31
+ // at all.
32
+ const namedExamples = examples && Object.keys(examples).length > 0 ? examples : undefined;
33
+ // `example` is a literal, so test presence rather than truthiness — `false`,
34
+ // `0` and `''` are all valid example values.
35
+ if (example !== undefined && examples !== undefined) {
35
36
  context.logIssue({
36
37
  key: 'example',
37
38
  level: 'warning',
38
- message: `Both example and examples are defined for ${exampleKey}`,
39
+ message: `Both example and examples are defined for ${exampleKey}; using ${namedExamples ? 'examples' : 'example'}`,
39
40
  parent: examples,
40
41
  stackTrail,
41
42
  type: 'EXAMPLE_AND_EXAMPLES_DEFINED'
42
43
  });
43
44
  }
44
- if (example) {
45
- return {
46
- [exampleKey]: stackTrail.trace('example', st => toExampleSimpleV3({ example, stackTrail: st, context }))
47
- };
48
- }
49
- if (examples) {
45
+ // The spec makes the two mutually exclusive, so reaching here with both is
46
+ // malformed input. Prefer `examples`: it is the richer field — many entries,
47
+ // each with a summary and description — and the singular carries nothing it
48
+ // cannot express, so this discards strictly less.
49
+ if (namedExamples) {
50
50
  return stackTrail.trace('examples', st => {
51
51
  const output = {};
52
- const entries = Object.entries(examples);
52
+ const entries = Object.entries(namedExamples);
53
53
  for (const [key, value] of entries) {
54
54
  output[key] = st.trace(key, st2 => toExampleV3({ example: value, stackTrail: st2, context }));
55
55
  }
56
56
  return output;
57
57
  });
58
58
  }
59
+ if (example !== undefined) {
60
+ return {
61
+ [exampleKey]: stackTrail.trace('example', st => toExampleSimpleV3({ example, stackTrail: st, context }))
62
+ };
63
+ }
59
64
  return undefined;
60
65
  };
61
66
  /**
@@ -72,7 +77,10 @@ export const toExampleV3 = ({ example, stackTrail, context }) => {
72
77
  if (isRef(example)) {
73
78
  return toRefV31({ ref: example, refType: 'example', stackTrail, context });
74
79
  }
75
- const { summary, description, value, ...skipped } = example;
80
+ // `externalValue` is the alternative to `value` — an example too large or too
81
+ // awkward to inline. Leaving it in `skipped` both loses it and reports a
82
+ // standard field as an unexpected property.
83
+ const { summary, description, value, externalValue, ...skipped } = example;
76
84
  const extensionFields = toSpecificationExtensionsV3({
77
85
  skipped,
78
86
  parent: example,
@@ -84,6 +92,7 @@ export const toExampleV3 = ({ example, stackTrail, context }) => {
84
92
  summary,
85
93
  description,
86
94
  value,
95
+ externalValue,
87
96
  extensionFields
88
97
  });
89
98
  };
@@ -11,6 +11,8 @@ export type ToHeadersV3Args = {
11
11
  export declare const toHeadersV3: ({ headers, stackTrail, context }: ToHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
12
12
  export type ToHeaderV3Args = {
13
13
  header: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
14
+ /** The header's name, used to key a singular `example` */
15
+ name: string;
14
16
  stackTrail: StackTrail;
15
17
  context: ParseContextType;
16
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-0/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eA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A;CAC1B,CAAA"}
@@ -12,11 +12,11 @@ export const toHeadersV3 = ({ headers, stackTrail, context }) => {
12
12
  const output = {};
13
13
  const entries = Object.entries(headers);
14
14
  for (const [key, value] of entries) {
15
- output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, stackTrail: st, context }));
15
+ output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, name: key, stackTrail: st, context }));
16
16
  }
17
17
  return output;
18
18
  };
19
- const toHeaderV3 = ({ header, stackTrail, context }) => {
19
+ const toHeaderV3 = ({ header, name, stackTrail, context }) => {
20
20
  if (isRef(header)) {
21
21
  return toRefV31({ ref: header, refType: 'header', stackTrail, context });
22
22
  }
@@ -36,7 +36,7 @@ const toHeaderV3 = ({ header, stackTrail, context }) => {
36
36
  examples: toExamplesV3({
37
37
  examples,
38
38
  example,
39
- exampleKey: `TEMP`,
39
+ exampleKey: name,
40
40
  stackTrail,
41
41
  context
42
42
  }),
@@ -4,7 +4,12 @@ import { OasExample } from '../../../oas/example/Example.js';
4
4
  import type { OasRef } from '../../../oas/ref/Ref.js';
5
5
  import type { StackTrail } from '../../../context/StackTrail.js';
6
6
  export type ToExampleSimpleV3Args = {
7
- example: OpenAPIV3.ExampleObject;
7
+ /**
8
+ * The example value itself. The singular `example` field of a media type,
9
+ * parameter or header is a LITERAL value — not an Example Object — so it
10
+ * carries no `summary`, `description` or `externalValue` to read.
11
+ */
12
+ example: unknown;
8
13
  /** The stack trail for tracing */
9
14
  stackTrail: StackTrail;
10
15
  /** Parse context for tracing and error handling */
@@ -13,8 +18,8 @@ export type ToExampleSimpleV3Args = {
13
18
  /**
14
19
  * Creates a simple OAS example from a value.
15
20
  *
16
- * Converts a raw example value into an OasExample object with basic
17
- * fields. Used for simple example scenarios where only the value matters.
21
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
22
+ * `example` field, where only the value exists.
18
23
  *
19
24
  * @param args - Arguments containing the example value
20
25
  * @returns OasExample object with the provided value
@@ -27,8 +32,8 @@ export declare const toExampleSimpleV3: ({ example }: ToExampleSimpleV3Args) =>
27
32
  * with context for tracing and error handling.
28
33
  */
29
34
  export type ToExamplesV3Args = {
30
- /** Single example object (OpenAPI v3 format) */
31
- example: OpenAPIV3.ExampleObject | undefined;
35
+ /** The singular `example` field — a literal value, not an Example Object */
36
+ example: unknown;
32
37
  /** Collection of named examples (OpenAPI v3 format) */
33
38
  examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
34
39
  /** Key name for the example context */
@@ -1 +1 @@
1
- {"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-1/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC,aAAa,CAAA;IAChC,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAE/B,qBAAqB,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CASvD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,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AU,GAAG,MAAM,CAAC,SAAS,CAIvD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAA;IAChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,wDAM1B,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SAiDtE,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAyBjD,CAAA"}
@@ -5,19 +5,14 @@ import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecif
5
5
  /**
6
6
  * Creates a simple OAS example from a value.
7
7
  *
8
- * Converts a raw example value into an OasExample object with basic
9
- * fields. Used for simple example scenarios where only the value matters.
8
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
9
+ * `example` field, where only the value exists.
10
10
  *
11
11
  * @param args - Arguments containing the example value
12
12
  * @returns OasExample object with the provided value
13
13
  */
14
14
  export const toExampleSimpleV3 = ({ example }) => {
15
- const fields = {
16
- value: example.value,
17
- summary: example.summary,
18
- description: example.description,
19
- externalValue: example.externalValue
20
- };
15
+ const fields = { value: example };
21
16
  return new OasExample(fields);
22
17
  };
23
18
  /**
@@ -31,31 +26,41 @@ export const toExampleSimpleV3 = ({ example }) => {
31
26
  * @returns Record of processed examples, or undefined if no examples
32
27
  */
33
28
  export const toExamplesV3 = ({ example, examples, exampleKey, stackTrail, context }) => {
34
- if (example && examples) {
29
+ // An empty map is declared but carries nothing, so it cannot be the richer
30
+ // field — letting it win would discard the singular in favour of no examples
31
+ // at all.
32
+ const namedExamples = examples && Object.keys(examples).length > 0 ? examples : undefined;
33
+ // `example` is a literal, so test presence rather than truthiness — `false`,
34
+ // `0` and `''` are all valid example values.
35
+ if (example !== undefined && examples !== undefined) {
35
36
  context.logIssue({
36
37
  key: 'example',
37
38
  level: 'warning',
38
- message: `Both example and examples are defined for ${exampleKey}`,
39
+ message: `Both example and examples are defined for ${exampleKey}; using ${namedExamples ? 'examples' : 'example'}`,
39
40
  parent: examples,
40
41
  stackTrail,
41
42
  type: 'EXAMPLE_AND_EXAMPLES_DEFINED'
42
43
  });
43
44
  }
44
- if (example) {
45
- return {
46
- [exampleKey]: stackTrail.trace('example', st => toExampleSimpleV3({ example, stackTrail: st, context }))
47
- };
48
- }
49
- if (examples) {
45
+ // The spec makes the two mutually exclusive, so reaching here with both is
46
+ // malformed input. Prefer `examples`: it is the richer field — many entries,
47
+ // each with a summary and description — and the singular carries nothing it
48
+ // cannot express, so this discards strictly less.
49
+ if (namedExamples) {
50
50
  return stackTrail.trace('examples', st => {
51
51
  const output = {};
52
- const entries = Object.entries(examples);
52
+ const entries = Object.entries(namedExamples);
53
53
  for (const [key, value] of entries) {
54
54
  output[key] = st.trace(key, st2 => toExampleV3({ example: value, stackTrail: st2, context }));
55
55
  }
56
56
  return output;
57
57
  });
58
58
  }
59
+ if (example !== undefined) {
60
+ return {
61
+ [exampleKey]: stackTrail.trace('example', st => toExampleSimpleV3({ example, stackTrail: st, context }))
62
+ };
63
+ }
59
64
  return undefined;
60
65
  };
61
66
  /**
@@ -72,7 +77,10 @@ export const toExampleV3 = ({ example, stackTrail, context }) => {
72
77
  if (isRef(example)) {
73
78
  return toRefV31({ ref: example, refType: 'example', stackTrail, context });
74
79
  }
75
- const { summary, description, value, ...skipped } = example;
80
+ // `externalValue` is the alternative to `value` — an example too large or too
81
+ // awkward to inline. Leaving it in `skipped` both loses it and reports a
82
+ // standard field as an unexpected property.
83
+ const { summary, description, value, externalValue, ...skipped } = example;
76
84
  const extensionFields = toSpecificationExtensionsV3({
77
85
  skipped,
78
86
  parent: example,
@@ -84,6 +92,7 @@ export const toExampleV3 = ({ example, stackTrail, context }) => {
84
92
  summary,
85
93
  description,
86
94
  value,
95
+ externalValue,
87
96
  extensionFields
88
97
  });
89
98
  };
@@ -11,6 +11,8 @@ export type ToHeadersV3Args = {
11
11
  export declare const toHeadersV3: ({ headers, stackTrail, context }: ToHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
12
12
  export type ToHeaderV3Args = {
13
13
  header: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
14
+ /** The header's name, used to key a singular `example` */
15
+ name: string;
14
16
  stackTrail: StackTrail;
15
17
  context: ParseContextType;
16
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-1/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CA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AY,CAAA;IAC1D,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
@@ -12,11 +12,11 @@ export const toHeadersV3 = ({ headers, stackTrail, context }) => {
12
12
  const output = {};
13
13
  const entries = Object.entries(headers);
14
14
  for (const [key, value] of entries) {
15
- output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, stackTrail: st, context }));
15
+ output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, name: key, stackTrail: st, context }));
16
16
  }
17
17
  return output;
18
18
  };
19
- const toHeaderV3 = ({ header, stackTrail, context }) => {
19
+ const toHeaderV3 = ({ header, name, stackTrail, context }) => {
20
20
  if (isRef(header)) {
21
21
  return toRefV31({ ref: header, refType: 'header', stackTrail, context });
22
22
  }
@@ -36,7 +36,7 @@ const toHeaderV3 = ({ header, stackTrail, context }) => {
36
36
  examples: toExamplesV3({
37
37
  examples,
38
38
  example,
39
- exampleKey: `TEMP`,
39
+ exampleKey: name,
40
40
  stackTrail,
41
41
  context
42
42
  }),
@@ -36,5 +36,11 @@ export type PackageDenoJson = {
36
36
  version: string;
37
37
  imports?: Record<string, string>;
38
38
  exports: Record<string, string> | string;
39
+ lint?: {
40
+ plugins?: string[];
41
+ rules?: {
42
+ exclude?: string[];
43
+ };
44
+ };
39
45
  };
40
46
  //# sourceMappingURL=DenoJson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DenoJson.d.ts","sourceRoot":"","sources":["../../src/types/DenoJson.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAIrD,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CA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AChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACxC,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAC/B,CAAA;CACF,CAAA"}
@@ -21,5 +21,9 @@ export const packageDenoJson = v.looseObject({
21
21
  name: v.string(),
22
22
  version: v.string(),
23
23
  imports: v.optional(v.record(v.string(), v.string())),
24
- exports: v.union([v.record(v.string(), v.string()), v.string()])
24
+ exports: v.union([v.record(v.string(), v.string()), v.string()]),
25
+ lint: v.optional(v.looseObject({
26
+ plugins: v.optional(v.array(v.string())),
27
+ rules: v.optional(v.looseObject({ exclude: v.optional(v.array(v.string())) }))
28
+ }))
25
29
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.28.2",
3
+ "version": "0.28.4",
4
4
  "description": "Skmtc is a declarative code generation framework",
5
5
  "keywords": [
6
6
  "openapi",
@@ -9,8 +9,8 @@ export type ExampleFields = {
9
9
  summary?: string;
10
10
  /** Longer description of the example */
11
11
  description?: string;
12
- /** The example value */
13
- value: unknown;
12
+ /** The example value — absent when the example is given as an `externalValue` */
13
+ value?: unknown;
14
14
  /** The external value of the example */
15
15
  externalValue?: string;
16
16
  /** Custom extension fields (x-* properties) */
@@ -1 +1 @@
1
- {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mCAAmC;IACnC,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AA;IACf,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,UAAU;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;IAC9B,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBAE7B,MAAM,EAAE,aAAa;IAQjC,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAUrE"}
@@ -62,7 +62,10 @@ class OasExample {
62
62
  return {
63
63
  summary: this.summary,
64
64
  description: this.description,
65
- value: this.value
65
+ value: this.value,
66
+ // Without this an `externalValue`-only example round-trips to an Example
67
+ // Object holding neither an inline value nor a pointer to one.
68
+ externalValue: this.externalValue
66
69
  };
67
70
  }
68
71
  }
@@ -4,7 +4,12 @@ import { OasExample } from '../../../oas/example/Example.js';
4
4
  import type { OasRef } from '../../../oas/ref/Ref.js';
5
5
  import type { StackTrail } from '../../../context/StackTrail.js';
6
6
  export type ToExampleSimpleV3Args = {
7
- example: OpenAPIV3.ExampleObject;
7
+ /**
8
+ * The example value itself. The singular `example` field of a media type,
9
+ * parameter or header is a LITERAL value — not an Example Object — so it
10
+ * carries no `summary`, `description` or `externalValue` to read.
11
+ */
12
+ example: unknown;
8
13
  /** The stack trail for tracing */
9
14
  stackTrail: StackTrail;
10
15
  /** Parse context for tracing and error handling */
@@ -13,8 +18,8 @@ export type ToExampleSimpleV3Args = {
13
18
  /**
14
19
  * Creates a simple OAS example from a value.
15
20
  *
16
- * Converts a raw example value into an OasExample object with basic
17
- * fields. Used for simple example scenarios where only the value matters.
21
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
22
+ * `example` field, where only the value exists.
18
23
  *
19
24
  * @param args - Arguments containing the example value
20
25
  * @returns OasExample object with the provided value
@@ -27,8 +32,8 @@ export declare const toExampleSimpleV3: ({ example }: ToExampleSimpleV3Args) =>
27
32
  * with context for tracing and error handling.
28
33
  */
29
34
  export type ToExamplesV3Args = {
30
- /** Single example object (OpenAPI v3 format) */
31
- example: OpenAPIV3.ExampleObject | undefined;
35
+ /** The singular `example` field — a literal value, not an Example Object */
36
+ example: unknown;
32
37
  /** Collection of named examples (OpenAPI v3 format) */
33
38
  examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
34
39
  /** Key name for the example context */
@@ -1 +1 @@
1
- {"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-0/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC,aAAa,CAAA;IAChC,kCAAkC;IAClC,UAAU,EAAE,UAAU,CAAA;IACtB,mDAAmD;IACnD,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAE/B,q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S example from a value.
10
10
  *
11
- * Converts a raw example value into an OasExample object with basic
12
- * fields. Used for simple example scenarios where only the value matters.
11
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
12
+ * `example` field, where only the value exists.
13
13
  *
14
14
  * @param args - Arguments containing the example value
15
15
  * @returns OasExample object with the provided value
16
16
  */
17
17
  const toExampleSimpleV3 = ({ example }) => {
18
- const fields = {
19
- value: example.value,
20
- summary: example.summary,
21
- description: example.description,
22
- externalValue: example.externalValue
23
- };
18
+ const fields = { value: example };
24
19
  return new Example_js_1.OasExample(fields);
25
20
  };
26
21
  exports.toExampleSimpleV3 = toExampleSimpleV3;
@@ -35,31 +30,41 @@ exports.toExampleSimpleV3 = toExampleSimpleV3;
35
30
  * @returns Record of processed examples, or undefined if no examples
36
31
  */
37
32
  const toExamplesV3 = ({ example, examples, exampleKey, stackTrail, context }) => {
38
- if (example && examples) {
33
+ // An empty map is declared but carries nothing, so it cannot be the richer
34
+ // field — letting it win would discard the singular in favour of no examples
35
+ // at all.
36
+ const namedExamples = examples && Object.keys(examples).length > 0 ? examples : undefined;
37
+ // `example` is a literal, so test presence rather than truthiness — `false`,
38
+ // `0` and `''` are all valid example values.
39
+ if (example !== undefined && examples !== undefined) {
39
40
  context.logIssue({
40
41
  key: 'example',
41
42
  level: 'warning',
42
- message: `Both example and examples are defined for ${exampleKey}`,
43
+ message: `Both example and examples are defined for ${exampleKey}; using ${namedExamples ? 'examples' : 'example'}`,
43
44
  parent: examples,
44
45
  stackTrail,
45
46
  type: 'EXAMPLE_AND_EXAMPLES_DEFINED'
46
47
  });
47
48
  }
48
- if (example) {
49
- return {
50
- [exampleKey]: stackTrail.trace('example', st => (0, exports.toExampleSimpleV3)({ example, stackTrail: st, context }))
51
- };
52
- }
53
- if (examples) {
49
+ // The spec makes the two mutually exclusive, so reaching here with both is
50
+ // malformed input. Prefer `examples`: it is the richer field — many entries,
51
+ // each with a summary and description — and the singular carries nothing it
52
+ // cannot express, so this discards strictly less.
53
+ if (namedExamples) {
54
54
  return stackTrail.trace('examples', st => {
55
55
  const output = {};
56
- const entries = Object.entries(examples);
56
+ const entries = Object.entries(namedExamples);
57
57
  for (const [key, value] of entries) {
58
58
  output[key] = st.trace(key, st2 => (0, exports.toExampleV3)({ example: value, stackTrail: st2, context }));
59
59
  }
60
60
  return output;
61
61
  });
62
62
  }
63
+ if (example !== undefined) {
64
+ return {
65
+ [exampleKey]: stackTrail.trace('example', st => (0, exports.toExampleSimpleV3)({ example, stackTrail: st, context }))
66
+ };
67
+ }
63
68
  return undefined;
64
69
  };
65
70
  exports.toExamplesV3 = toExamplesV3;
@@ -77,7 +82,10 @@ const toExampleV3 = ({ example, stackTrail, context }) => {
77
82
  if ((0, refFns_js_1.isRef)(example)) {
78
83
  return (0, toRefV31_js_1.toRefV31)({ ref: example, refType: 'example', stackTrail, context });
79
84
  }
80
- const { summary, description, value, ...skipped } = example;
85
+ // `externalValue` is the alternative to `value` — an example too large or too
86
+ // awkward to inline. Leaving it in `skipped` both loses it and reports a
87
+ // standard field as an unexpected property.
88
+ const { summary, description, value, externalValue, ...skipped } = example;
81
89
  const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
82
90
  skipped,
83
91
  parent: example,
@@ -89,6 +97,7 @@ const toExampleV3 = ({ example, stackTrail, context }) => {
89
97
  summary,
90
98
  description,
91
99
  value,
100
+ externalValue,
92
101
  extensionFields
93
102
  });
94
103
  };
@@ -11,6 +11,8 @@ export type ToHeadersV3Args = {
11
11
  export declare const toHeadersV3: ({ headers, stackTrail, context }: ToHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
12
12
  export type ToHeaderV3Args = {
13
13
  header: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
14
+ /** The header's name, used to key a singular `example` */
15
+ name: string;
14
16
  stackTrail: StackTrail;
15
17
  context: ParseContextType;
16
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-0/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAenE,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
1
+ {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-0/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAenE,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
@@ -15,12 +15,12 @@ const toHeadersV3 = ({ headers, stackTrail, context }) => {
15
15
  const output = {};
16
16
  const entries = Object.entries(headers);
17
17
  for (const [key, value] of entries) {
18
- output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, stackTrail: st, context }));
18
+ output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, name: key, stackTrail: st, context }));
19
19
  }
20
20
  return output;
21
21
  };
22
22
  exports.toHeadersV3 = toHeadersV3;
23
- const toHeaderV3 = ({ header, stackTrail, context }) => {
23
+ const toHeaderV3 = ({ header, name, stackTrail, context }) => {
24
24
  if ((0, refFns_js_1.isRef)(header)) {
25
25
  return (0, toRefV31_js_1.toRefV31)({ ref: header, refType: 'header', stackTrail, context });
26
26
  }
@@ -40,7 +40,7 @@ const toHeaderV3 = ({ header, stackTrail, context }) => {
40
40
  examples: (0, toExamplesV3_js_1.toExamplesV3)({
41
41
  examples,
42
42
  example,
43
- exampleKey: `TEMP`,
43
+ exampleKey: name,
44
44
  stackTrail,
45
45
  context
46
46
  }),
@@ -4,7 +4,12 @@ import { OasExample } from '../../../oas/example/Example.js';
4
4
  import type { OasRef } from '../../../oas/ref/Ref.js';
5
5
  import type { StackTrail } from '../../../context/StackTrail.js';
6
6
  export type ToExampleSimpleV3Args = {
7
- example: OpenAPIV3.ExampleObject;
7
+ /**
8
+ * The example value itself. The singular `example` field of a media type,
9
+ * parameter or header is a LITERAL value — not an Example Object — so it
10
+ * carries no `summary`, `description` or `externalValue` to read.
11
+ */
12
+ example: unknown;
8
13
  /** The stack trail for tracing */
9
14
  stackTrail: StackTrail;
10
15
  /** Parse context for tracing and error handling */
@@ -13,8 +18,8 @@ export type ToExampleSimpleV3Args = {
13
18
  /**
14
19
  * Creates a simple OAS example from a value.
15
20
  *
16
- * Converts a raw example value into an OasExample object with basic
17
- * fields. Used for simple example scenarios where only the value matters.
21
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
22
+ * `example` field, where only the value exists.
18
23
  *
19
24
  * @param args - Arguments containing the example value
20
25
  * @returns OasExample object with the provided value
@@ -27,8 +32,8 @@ export declare const toExampleSimpleV3: ({ example }: ToExampleSimpleV3Args) =>
27
32
  * with context for tracing and error handling.
28
33
  */
29
34
  export type ToExamplesV3Args = {
30
- /** Single example object (OpenAPI v3 format) */
31
- example: OpenAPIV3.ExampleObject | undefined;
35
+ /** The singular `example` field — a literal value, not an Example Object */
36
+ example: unknown;
32
37
  /** Collection of named examples (OpenAPI v3 format) */
33
38
  examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
34
39
  /** Key name for the example context */
@@ -1 +1 @@
1
- {"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-1/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D,OAAO,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OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAyBjD,CAAA"}
@@ -8,19 +8,14 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
8
8
  /**
9
9
  * Creates a simple OAS example from a value.
10
10
  *
11
- * Converts a raw example value into an OasExample object with basic
12
- * fields. Used for simple example scenarios where only the value matters.
11
+ * Wraps a literal example value as an {@link OasExample}. Used for the singular
12
+ * `example` field, where only the value exists.
13
13
  *
14
14
  * @param args - Arguments containing the example value
15
15
  * @returns OasExample object with the provided value
16
16
  */
17
17
  const toExampleSimpleV3 = ({ example }) => {
18
- const fields = {
19
- value: example.value,
20
- summary: example.summary,
21
- description: example.description,
22
- externalValue: example.externalValue
23
- };
18
+ const fields = { value: example };
24
19
  return new Example_js_1.OasExample(fields);
25
20
  };
26
21
  exports.toExampleSimpleV3 = toExampleSimpleV3;
@@ -35,31 +30,41 @@ exports.toExampleSimpleV3 = toExampleSimpleV3;
35
30
  * @returns Record of processed examples, or undefined if no examples
36
31
  */
37
32
  const toExamplesV3 = ({ example, examples, exampleKey, stackTrail, context }) => {
38
- if (example && examples) {
33
+ // An empty map is declared but carries nothing, so it cannot be the richer
34
+ // field — letting it win would discard the singular in favour of no examples
35
+ // at all.
36
+ const namedExamples = examples && Object.keys(examples).length > 0 ? examples : undefined;
37
+ // `example` is a literal, so test presence rather than truthiness — `false`,
38
+ // `0` and `''` are all valid example values.
39
+ if (example !== undefined && examples !== undefined) {
39
40
  context.logIssue({
40
41
  key: 'example',
41
42
  level: 'warning',
42
- message: `Both example and examples are defined for ${exampleKey}`,
43
+ message: `Both example and examples are defined for ${exampleKey}; using ${namedExamples ? 'examples' : 'example'}`,
43
44
  parent: examples,
44
45
  stackTrail,
45
46
  type: 'EXAMPLE_AND_EXAMPLES_DEFINED'
46
47
  });
47
48
  }
48
- if (example) {
49
- return {
50
- [exampleKey]: stackTrail.trace('example', st => (0, exports.toExampleSimpleV3)({ example, stackTrail: st, context }))
51
- };
52
- }
53
- if (examples) {
49
+ // The spec makes the two mutually exclusive, so reaching here with both is
50
+ // malformed input. Prefer `examples`: it is the richer field — many entries,
51
+ // each with a summary and description — and the singular carries nothing it
52
+ // cannot express, so this discards strictly less.
53
+ if (namedExamples) {
54
54
  return stackTrail.trace('examples', st => {
55
55
  const output = {};
56
- const entries = Object.entries(examples);
56
+ const entries = Object.entries(namedExamples);
57
57
  for (const [key, value] of entries) {
58
58
  output[key] = st.trace(key, st2 => (0, exports.toExampleV3)({ example: value, stackTrail: st2, context }));
59
59
  }
60
60
  return output;
61
61
  });
62
62
  }
63
+ if (example !== undefined) {
64
+ return {
65
+ [exampleKey]: stackTrail.trace('example', st => (0, exports.toExampleSimpleV3)({ example, stackTrail: st, context }))
66
+ };
67
+ }
63
68
  return undefined;
64
69
  };
65
70
  exports.toExamplesV3 = toExamplesV3;
@@ -77,7 +82,10 @@ const toExampleV3 = ({ example, stackTrail, context }) => {
77
82
  if ((0, refFns_js_1.isRef)(example)) {
78
83
  return (0, toRefV31_js_1.toRefV31)({ ref: example, refType: 'example', stackTrail, context });
79
84
  }
80
- const { summary, description, value, ...skipped } = example;
85
+ // `externalValue` is the alternative to `value` — an example too large or too
86
+ // awkward to inline. Leaving it in `skipped` both loses it and reports a
87
+ // standard field as an unexpected property.
88
+ const { summary, description, value, externalValue, ...skipped } = example;
81
89
  const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
82
90
  skipped,
83
91
  parent: example,
@@ -89,6 +97,7 @@ const toExampleV3 = ({ example, stackTrail, context }) => {
89
97
  summary,
90
98
  description,
91
99
  value,
100
+ externalValue,
92
101
  extensionFields
93
102
  });
94
103
  };
@@ -11,6 +11,8 @@ export type ToHeadersV3Args = {
11
11
  export declare const toHeadersV3: ({ headers, stackTrail, context }: ToHeadersV3Args) => Record<string, OasHeader | OasRef<"header">> | undefined;
12
12
  export type ToHeaderV3Args = {
13
13
  header: OpenAPIV3.ReferenceObject | OpenAPIV3.HeaderObject;
14
+ /** The header's name, used to key a singular `example` */
15
+ name: string;
14
16
  stackTrail: StackTrail;
15
17
  context: ParseContextType;
16
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-1/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAenE,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
1
+ {"version":3,"file":"toHeadersV3.d.ts","sourceRoot":"","sources":["../../../../src/parse/v3-1/header/toHeadersV3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,kCAIzB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAenE,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
@@ -15,12 +15,12 @@ const toHeadersV3 = ({ headers, stackTrail, context }) => {
15
15
  const output = {};
16
16
  const entries = Object.entries(headers);
17
17
  for (const [key, value] of entries) {
18
- output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, stackTrail: st, context }));
18
+ output[key] = stackTrail.trace(key, st => toHeaderV3({ header: value, name: key, stackTrail: st, context }));
19
19
  }
20
20
  return output;
21
21
  };
22
22
  exports.toHeadersV3 = toHeadersV3;
23
- const toHeaderV3 = ({ header, stackTrail, context }) => {
23
+ const toHeaderV3 = ({ header, name, stackTrail, context }) => {
24
24
  if ((0, refFns_js_1.isRef)(header)) {
25
25
  return (0, toRefV31_js_1.toRefV31)({ ref: header, refType: 'header', stackTrail, context });
26
26
  }
@@ -40,7 +40,7 @@ const toHeaderV3 = ({ header, stackTrail, context }) => {
40
40
  examples: (0, toExamplesV3_js_1.toExamplesV3)({
41
41
  examples,
42
42
  example,
43
- exampleKey: `TEMP`,
43
+ exampleKey: name,
44
44
  stackTrail,
45
45
  context
46
46
  }),
@@ -36,5 +36,11 @@ export type PackageDenoJson = {
36
36
  version: string;
37
37
  imports?: Record<string, string>;
38
38
  exports: Record<string, string> | string;
39
+ lint?: {
40
+ plugins?: string[];
41
+ rules?: {
42
+ exclude?: string[];
43
+ };
44
+ };
39
45
  };
40
46
  //# sourceMappingURL=DenoJson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DenoJson.d.ts","sourceRoot":"","sources":["../../src/types/DenoJson.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAIrD,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,aAAa,CAAC,eAAe,CAK3D,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CACzC,CAAA"}
1
+ {"version":3,"file":"DenoJson.d.ts","sourceRoot":"","sources":["../../src/types/DenoJson.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAIrD,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,aAAa,CAAC,eAAe,CAW3D,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACxC,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAC/B,CAAA;CACF,CAAA"}
@@ -57,5 +57,9 @@ exports.packageDenoJson = v.looseObject({
57
57
  name: v.string(),
58
58
  version: v.string(),
59
59
  imports: v.optional(v.record(v.string(), v.string())),
60
- exports: v.union([v.record(v.string(), v.string()), v.string()])
60
+ exports: v.union([v.record(v.string(), v.string()), v.string()]),
61
+ lint: v.optional(v.looseObject({
62
+ plugins: v.optional(v.array(v.string())),
63
+ rules: v.optional(v.looseObject({ exclude: v.optional(v.array(v.string())) }))
64
+ }))
61
65
  });