@skmtc/core 0.0.445 → 0.0.447

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 +1 @@
1
- {"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAgCvC,CAAA"}
1
+ {"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAkCvC,CAAA"}
@@ -13,7 +13,7 @@ export const toComponentsV3 = ({ components, context }) => {
13
13
  const { schemas, responses, parameters, examples, requestBodies, headers, ...skipped } = components;
14
14
  const extensionFields = toSpecificationExtensionsV3({ skipped, context });
15
15
  const fields = {
16
- schemas: context.trace('schemas', () => toOptionalSchemasV3({ schemas, context })),
16
+ schemas: context.trace('schemas', () => toOptionalSchemasV3({ schemas, context, childOfComponents: true })),
17
17
  responses: context.trace('responses', () => toOptionalResponsesV3({ responses, context })),
18
18
  parameters: context.trace('parameters', () => toOptionalParametersV3({
19
19
  parameters,
@@ -4,7 +4,8 @@ import { OasObject } from './Object.js';
4
4
  type ToObjectArgs = {
5
5
  value: OpenAPIV3.NonArraySchemaObject;
6
6
  context: ParseContext;
7
+ childOfComponents?: boolean;
7
8
  };
8
- export declare const toObject: ({ value, context }: ToObjectArgs) => OasObject;
9
+ export declare const toObject: ({ value, context, childOfComponents }: ToObjectArgs) => OasObject;
9
10
  export {};
10
11
  //# sourceMappingURL=toObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toObject.d.ts","sourceRoot":"","sources":["../../../src/oas/object/toObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAA;AAK7D,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAA;IACrC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,QAAQ,uBAAwB,YAAY,KAAG,SA+C3D,CAAA"}
1
+ {"version":3,"file":"toObject.d.ts","sourceRoot":"","sources":["../../../src/oas/object/toObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAA;AAK7D,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAA;IACrC,OAAO,EAAE,YAAY,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,QAAQ,0CAA2C,YAAY,KAAG,SAsC9E,CAAA"}
@@ -2,20 +2,12 @@ import { OasObject } from './Object.js';
2
2
  import { toOptionalSchemasV3 } from '../schema/toSchemasV3.js';
3
3
  import { toAdditionalPropertiesV3 } from './toAdditionalPropertiesV3.js';
4
4
  import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecificationExtensionsV3.js';
5
- export const toObject = ({ value, context }) => {
5
+ export const toObject = ({ value, context, childOfComponents }) => {
6
6
  const { type: _type, title, description, properties, required, additionalProperties, nullable, example, ...skipped } = value;
7
7
  const extensionFields = toSpecificationExtensionsV3({
8
8
  skipped,
9
9
  context
10
10
  });
11
- if (extensionFields && Object.keys(extensionFields).length > 0) {
12
- const last = context.stackTrail.stackTrail.slice(-1);
13
- context.registerExtension({
14
- extensionFields,
15
- type: 'model',
16
- stackTrail: ['models', last.toString()]
17
- });
18
- }
19
11
  const fields = {
20
12
  title,
21
13
  description,
@@ -23,7 +15,8 @@ export const toObject = ({ value, context }) => {
23
15
  example,
24
16
  properties: context.trace('properties', () => toOptionalSchemasV3({
25
17
  schemas: properties,
26
- context
18
+ context,
19
+ childOfObject: childOfComponents
27
20
  })),
28
21
  required: required,
29
22
  additionalProperties: context.trace('additionalProperties', () => toAdditionalPropertiesV3({ additionalProperties, context })),
@@ -5,18 +5,23 @@ import type { OasRef } from '../ref/Ref.js';
5
5
  type ToSchemasV3Args = {
6
6
  schemas: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;
7
7
  context: ParseContext;
8
+ childOfComponents?: boolean;
9
+ childOfObject?: boolean;
8
10
  };
9
- export declare const toSchemasV3: ({ schemas, context }: ToSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">>;
11
+ export declare const toSchemasV3: ({ schemas, context, childOfComponents, childOfObject }: ToSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">>;
10
12
  type ToOptionalSchemasV3Args = {
11
13
  schemas: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject> | undefined;
12
14
  context: ParseContext;
15
+ childOfComponents?: boolean;
16
+ childOfObject?: boolean;
13
17
  };
14
- export declare const toOptionalSchemasV3: ({ schemas, context }: ToOptionalSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">> | undefined;
18
+ export declare const toOptionalSchemasV3: ({ schemas, context, childOfComponents, childOfObject }: ToOptionalSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">> | undefined;
15
19
  type ToSchemaV3Args = {
16
20
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
17
21
  context: ParseContext;
22
+ childOfComponents?: boolean;
18
23
  };
19
- export declare const toSchemaV3: ({ schema, context }: ToSchemaV3Args) => OasSchema | OasRef<"schema">;
24
+ export declare const toSchemaV3: ({ schema, context, childOfComponents }: ToSchemaV3Args) => OasSchema | OasRef<"schema">;
20
25
  type ToOptionalSchemaV3Args = {
21
26
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
22
27
  context: ParseContext;
@@ -1 +1 @@
1
- {"version":3,"file":"toSchemasV3.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/toSchemasV3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAW3C,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;IAC3E,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW,yBAGrB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QA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{ toUnion } from '../union/toUnion.js';
12
12
  import { toIntersection } from '../intersection/toIntersection.js';
13
- export const toSchemasV3 = ({ schemas, context }) => {
13
+ import { extractExtensions } from '../specificationExtensions/toSpecificationExtensionsV3.js';
14
+ export const toSchemasV3 = ({ schemas, context, childOfComponents, childOfObject }) => {
14
15
  return Object.fromEntries(Object.entries(schemas).map(([key, schema]) => {
15
- return [key, context.trace(key, () => toSchemaV3({ schema, context }))];
16
+ return [
17
+ key,
18
+ context.trace(key, () => {
19
+ if ((childOfComponents || childOfObject) && !isRef(schema)) {
20
+ const { extensionFields } = extractExtensions(schema);
21
+ const parent = context.stackTrail.stackTrail.slice(-2, -1).at(0);
22
+ const stackTrail = childOfComponents ? ['models', key] : ['models', String(parent), key];
23
+ context.registerExtension({
24
+ extensionFields: extensionFields ?? {},
25
+ stackTrail,
26
+ type: 'schema'
27
+ });
28
+ }
29
+ return toSchemaV3({ schema, context });
30
+ })
31
+ ];
16
32
  }));
17
33
  };
18
- export const toOptionalSchemasV3 = ({ schemas, context }) => {
34
+ export const toOptionalSchemasV3 = ({ schemas, context, childOfComponents, childOfObject }) => {
19
35
  if (!schemas) {
20
36
  return undefined;
21
37
  }
22
- return toSchemasV3({ schemas, context });
38
+ return toSchemasV3({ schemas, context, childOfComponents, childOfObject });
23
39
  };
24
- export const toSchemaV3 = ({ schema, context }) => {
40
+ export const toSchemaV3 = ({ schema, context, childOfComponents }) => {
25
41
  if (isRef(schema)) {
26
42
  return toRefV31({ ref: schema, refType: 'schema', context });
27
43
  }
@@ -48,7 +64,7 @@ export const toSchemaV3 = ({ schema, context }) => {
48
64
  // }
49
65
  return context.trace('allOf', () => toIntersection({ value, members, context }));
50
66
  })
51
- .with({ type: 'object' }, value => toObject({ value, context }))
67
+ .with({ type: 'object' }, value => toObject({ value, context, childOfComponents }))
52
68
  .with({ type: 'array' }, value => toArray({ value, context }))
53
69
  .with({ type: 'integer' }, value => toInteger({ value, context }))
54
70
  .with({ type: 'number' }, value => toNumber({ value, context }))
@@ -4,5 +4,9 @@ type ToSpecificationExtensionsV3Args = {
4
4
  context: ParseContext;
5
5
  };
6
6
  export declare const toSpecificationExtensionsV3: ({ skipped: s, context }: ToSpecificationExtensionsV3Args) => Record<string, unknown> | undefined;
7
+ export declare const extractExtensions: (item: Record<string, unknown>) => {
8
+ skipped: Record<string, unknown>;
9
+ extensionFields: Record<string, unknown> | undefined;
10
+ };
7
11
  export {};
8
12
  //# sourceMappingURL=toSpecificationExtensionsV3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toSpecificationExtensionsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/specificationExtensions/toSpecificationExtensionsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,2BAA2B,4BAGrC,+BAA+B,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SA4B9D,CAAA"}
1
+ {"version":3,"file":"toSpecificationExtensionsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/specificationExtensions/toSpecificationExtensionsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,2BAA2B,4BAGrC,+BAA+B,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAM9D,CAAA;AAED,eAAO,MAAM,iBAAiB,SAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;aAElD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAqBvD,CAAA"}
@@ -1,5 +1,10 @@
1
1
  export const toSpecificationExtensionsV3 = ({ skipped: s, context }) => {
2
- const { skipped, extensionFields } = Object.entries(s).reduce((acc, [key, value]) => {
2
+ const { skipped, extensionFields } = extractExtensions(s);
3
+ context.logSkippedFields(skipped);
4
+ return extensionFields;
5
+ };
6
+ export const extractExtensions = (item) => {
7
+ return Object.entries(item).reduce((acc, [key, value]) => {
3
8
  if (!key.startsWith('x-')) {
4
9
  return acc;
5
10
  }
@@ -12,7 +17,5 @@ export const toSpecificationExtensionsV3 = ({ skipped: s, context }) => {
12
17
  [key]: value
13
18
  }
14
19
  };
15
- }, { skipped: s, extensionFields: undefined });
16
- context.logSkippedFields(skipped);
17
- return extensionFields;
20
+ }, { skipped: item, extensionFields: undefined });
18
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.445",
3
+ "version": "0.0.447",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAgCvC,CAAA"}
1
+ {"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAkCvC,CAAA"}
@@ -16,7 +16,7 @@ const toComponentsV3 = ({ components, context }) => {
16
16
  const { schemas, responses, parameters, examples, requestBodies, headers, ...skipped } = components;
17
17
  const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({ skipped, context });
18
18
  const fields = {
19
- schemas: context.trace('schemas', () => (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas, context })),
19
+ schemas: context.trace('schemas', () => (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas, context, childOfComponents: true })),
20
20
  responses: context.trace('responses', () => (0, toResponseV3_js_1.toOptionalResponsesV3)({ responses, context })),
21
21
  parameters: context.trace('parameters', () => (0, toParameterV3_js_1.toOptionalParametersV3)({
22
22
  parameters,
@@ -4,7 +4,8 @@ import { OasObject } from './Object.js';
4
4
  type ToObjectArgs = {
5
5
  value: OpenAPIV3.NonArraySchemaObject;
6
6
  context: ParseContext;
7
+ childOfComponents?: boolean;
7
8
  };
8
- export declare const toObject: ({ value, context }: ToObjectArgs) => OasObject;
9
+ export declare const toObject: ({ value, context, childOfComponents }: ToObjectArgs) => OasObject;
9
10
  export {};
10
11
  //# sourceMappingURL=toObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toObject.d.ts","sourceRoot":"","sources":["../../../src/oas/object/toObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAA;AAK7D,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAA;IACrC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,QAAQ,uBAAwB,YAAY,KAAG,SA+C3D,CAAA"}
1
+ {"version":3,"file":"toObject.d.ts","sourceRoot":"","sources":["../../../src/oas/object/toObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAA;AAK7D,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,SAAS,CAAC,oBAAoB,CAAA;IACrC,OAAO,EAAE,YAAY,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,QAAQ,0CAA2C,YAAY,KAAG,SAsC9E,CAAA"}
@@ -5,20 +5,12 @@ const Object_js_1 = require("./Object.js");
5
5
  const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
6
6
  const toAdditionalPropertiesV3_js_1 = require("./toAdditionalPropertiesV3.js");
7
7
  const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
8
- const toObject = ({ value, context }) => {
8
+ const toObject = ({ value, context, childOfComponents }) => {
9
9
  const { type: _type, title, description, properties, required, additionalProperties, nullable, example, ...skipped } = value;
10
10
  const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({
11
11
  skipped,
12
12
  context
13
13
  });
14
- if (extensionFields && Object.keys(extensionFields).length > 0) {
15
- const last = context.stackTrail.stackTrail.slice(-1);
16
- context.registerExtension({
17
- extensionFields,
18
- type: 'model',
19
- stackTrail: ['models', last.toString()]
20
- });
21
- }
22
14
  const fields = {
23
15
  title,
24
16
  description,
@@ -26,7 +18,8 @@ const toObject = ({ value, context }) => {
26
18
  example,
27
19
  properties: context.trace('properties', () => (0, toSchemasV3_js_1.toOptionalSchemasV3)({
28
20
  schemas: properties,
29
- context
21
+ context,
22
+ childOfObject: childOfComponents
30
23
  })),
31
24
  required: required,
32
25
  additionalProperties: context.trace('additionalProperties', () => (0, toAdditionalPropertiesV3_js_1.toAdditionalPropertiesV3)({ additionalProperties, context })),
@@ -5,18 +5,23 @@ import type { OasRef } from '../ref/Ref.js';
5
5
  type ToSchemasV3Args = {
6
6
  schemas: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;
7
7
  context: ParseContext;
8
+ childOfComponents?: boolean;
9
+ childOfObject?: boolean;
8
10
  };
9
- export declare const toSchemasV3: ({ schemas, context }: ToSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">>;
11
+ export declare const toSchemasV3: ({ schemas, context, childOfComponents, childOfObject }: ToSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">>;
10
12
  type ToOptionalSchemasV3Args = {
11
13
  schemas: Record<string, OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject> | undefined;
12
14
  context: ParseContext;
15
+ childOfComponents?: boolean;
16
+ childOfObject?: boolean;
13
17
  };
14
- export declare const toOptionalSchemasV3: ({ schemas, context }: ToOptionalSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">> | undefined;
18
+ export declare const toOptionalSchemasV3: ({ schemas, context, childOfComponents, childOfObject }: ToOptionalSchemasV3Args) => Record<string, OasSchema | OasRef<"schema">> | undefined;
15
19
  type ToSchemaV3Args = {
16
20
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
17
21
  context: ParseContext;
22
+ childOfComponents?: boolean;
18
23
  };
19
- export declare const toSchemaV3: ({ schema, context }: ToSchemaV3Args) => OasSchema | OasRef<"schema">;
24
+ export declare const toSchemaV3: ({ schema, context, childOfComponents }: ToSchemaV3Args) => OasSchema | OasRef<"schema">;
20
25
  type ToOptionalSchemaV3Args = {
21
26
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
22
27
  context: ParseContext;
@@ -1 +1 @@
1
- {"version":3,"file":"toSchemasV3.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/toSchemasV3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAW3C,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;IAC3E,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW,yBAGrB,eAAe,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAM/D,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IACvF,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,mBAAmB,yBAG7B,uBAAuB,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAM3E,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,OAAO,EAAE,YAAY,CAA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AC3B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,mBAAmB,2DAK7B,uBAAuB,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAM3E,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,CAAA;IAC1D,OAAO,EAAE,YAAY,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,UAAU,2CAIpB,cAAc,KAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAuC9C,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,YAAY,GAAG,SAAS,CAAA;IACtE,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,kBAAkB,wBAG5B,sBAAsB,KAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAM1D,CAAA"}
@@ -13,20 +13,36 @@ const toString_js_1 = require("../string/toString.js");
13
13
  const toUnknown_js_1 = require("../unknown/toUnknown.js");
14
14
  const toUnion_js_1 = require("../union/toUnion.js");
15
15
  const toIntersection_js_1 = require("../intersection/toIntersection.js");
16
- const toSchemasV3 = ({ schemas, context }) => {
16
+ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
17
+ const toSchemasV3 = ({ schemas, context, childOfComponents, childOfObject }) => {
17
18
  return Object.fromEntries(Object.entries(schemas).map(([key, schema]) => {
18
- return [key, context.trace(key, () => (0, exports.toSchemaV3)({ schema, context }))];
19
+ return [
20
+ key,
21
+ context.trace(key, () => {
22
+ if ((childOfComponents || childOfObject) && !(0, refFns_js_1.isRef)(schema)) {
23
+ const { extensionFields } = (0, toSpecificationExtensionsV3_js_1.extractExtensions)(schema);
24
+ const parent = context.stackTrail.stackTrail.slice(-2, -1).at(0);
25
+ const stackTrail = childOfComponents ? ['models', key] : ['models', String(parent), key];
26
+ context.registerExtension({
27
+ extensionFields: extensionFields ?? {},
28
+ stackTrail,
29
+ type: 'schema'
30
+ });
31
+ }
32
+ return (0, exports.toSchemaV3)({ schema, context });
33
+ })
34
+ ];
19
35
  }));
20
36
  };
21
37
  exports.toSchemasV3 = toSchemasV3;
22
- const toOptionalSchemasV3 = ({ schemas, context }) => {
38
+ const toOptionalSchemasV3 = ({ schemas, context, childOfComponents, childOfObject }) => {
23
39
  if (!schemas) {
24
40
  return undefined;
25
41
  }
26
- return (0, exports.toSchemasV3)({ schemas, context });
42
+ return (0, exports.toSchemasV3)({ schemas, context, childOfComponents, childOfObject });
27
43
  };
28
44
  exports.toOptionalSchemasV3 = toOptionalSchemasV3;
29
- const toSchemaV3 = ({ schema, context }) => {
45
+ const toSchemaV3 = ({ schema, context, childOfComponents }) => {
30
46
  if ((0, refFns_js_1.isRef)(schema)) {
31
47
  return (0, toRefV31_js_1.toRefV31)({ ref: schema, refType: 'schema', context });
32
48
  }
@@ -53,7 +69,7 @@ const toSchemaV3 = ({ schema, context }) => {
53
69
  // }
54
70
  return context.trace('allOf', () => (0, toIntersection_js_1.toIntersection)({ value, members, context }));
55
71
  })
56
- .with({ type: 'object' }, value => (0, toObject_js_1.toObject)({ value, context }))
72
+ .with({ type: 'object' }, value => (0, toObject_js_1.toObject)({ value, context, childOfComponents }))
57
73
  .with({ type: 'array' }, value => (0, toArray_js_1.toArray)({ value, context }))
58
74
  .with({ type: 'integer' }, value => (0, toInteger_js_1.toInteger)({ value, context }))
59
75
  .with({ type: 'number' }, value => (0, toNumber_js_1.toNumber)({ value, context }))
@@ -4,5 +4,9 @@ type ToSpecificationExtensionsV3Args = {
4
4
  context: ParseContext;
5
5
  };
6
6
  export declare const toSpecificationExtensionsV3: ({ skipped: s, context }: ToSpecificationExtensionsV3Args) => Record<string, unknown> | undefined;
7
+ export declare const extractExtensions: (item: Record<string, unknown>) => {
8
+ skipped: Record<string, unknown>;
9
+ extensionFields: Record<string, unknown> | undefined;
10
+ };
7
11
  export {};
8
12
  //# sourceMappingURL=toSpecificationExtensionsV3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toSpecificationExtensionsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/specificationExtensions/toSpecificationExtensionsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,2BAA2B,4BAGrC,+BAA+B,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SA4B9D,CAAA"}
1
+ {"version":3,"file":"toSpecificationExtensionsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/specificationExtensions/toSpecificationExtensionsV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,2BAA2B,4BAGrC,+BAA+B,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAM9D,CAAA;AAED,eAAO,MAAM,iBAAiB,SAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;aAElD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAqBvD,CAAA"}
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toSpecificationExtensionsV3 = void 0;
3
+ exports.extractExtensions = exports.toSpecificationExtensionsV3 = void 0;
4
4
  const toSpecificationExtensionsV3 = ({ skipped: s, context }) => {
5
- const { skipped, extensionFields } = Object.entries(s).reduce((acc, [key, value]) => {
5
+ const { skipped, extensionFields } = (0, exports.extractExtensions)(s);
6
+ context.logSkippedFields(skipped);
7
+ return extensionFields;
8
+ };
9
+ exports.toSpecificationExtensionsV3 = toSpecificationExtensionsV3;
10
+ const extractExtensions = (item) => {
11
+ return Object.entries(item).reduce((acc, [key, value]) => {
6
12
  if (!key.startsWith('x-')) {
7
13
  return acc;
8
14
  }
@@ -15,8 +21,6 @@ const toSpecificationExtensionsV3 = ({ skipped: s, context }) => {
15
21
  [key]: value
16
22
  }
17
23
  };
18
- }, { skipped: s, extensionFields: undefined });
19
- context.logSkippedFields(skipped);
20
- return extensionFields;
24
+ }, { skipped: item, extensionFields: undefined });
21
25
  };
22
- exports.toSpecificationExtensionsV3 = toSpecificationExtensionsV3;
26
+ exports.extractExtensions = extractExtensions;