json-machete 0.5.0-alpha-2d2fd0541.0 → 0.5.1

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 (3) hide show
  1. package/index.js +19 -0
  2. package/index.mjs +19 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -356,6 +356,7 @@ function getCwd(path$1) {
356
356
  }
357
357
  // eslint-disable-next-line @typescript-eslint/ban-types
358
358
  async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetch = crossUndiciFetch.fetch, headers, } = {}) {
359
+ var _a;
359
360
  if (typeof obj === 'object') {
360
361
  if (isRefObject(obj)) {
361
362
  const $ref = obj.$ref;
@@ -377,6 +378,24 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
377
378
  throw new Error(`Unable to load ${externalRelativeFilePath} from ${cwd}`);
378
379
  });
379
380
  externalFileCache.set(externalFilePath, externalFile);
381
+ // Title should not be overwritten by the title given from the reference
382
+ // Usually Swagger and OpenAPI Schemas have this
383
+ if (externalFile.definitions) {
384
+ for (const definitionName in externalFile.definitions) {
385
+ const definition = externalFile.definitions[definitionName];
386
+ if (!definition.title) {
387
+ definition.title = definitionName;
388
+ }
389
+ }
390
+ }
391
+ if ((_a = externalFile.components) === null || _a === void 0 ? void 0 : _a.schemas) {
392
+ for (const definitionName in externalFile.components.schemas) {
393
+ const definition = externalFile.components.schemas[definitionName];
394
+ if (!definition.title) {
395
+ definition.title = definitionName;
396
+ }
397
+ }
398
+ }
380
399
  }
381
400
  const result = await dereferenceObject(refPath
382
401
  ? {
package/index.mjs CHANGED
@@ -351,6 +351,7 @@ function getCwd(path) {
351
351
  }
352
352
  // eslint-disable-next-line @typescript-eslint/ban-types
353
353
  async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache = new Map(), refMap = new Map(), root = obj, fetch: fetch$1 = fetch, headers, } = {}) {
354
+ var _a;
354
355
  if (typeof obj === 'object') {
355
356
  if (isRefObject(obj)) {
356
357
  const $ref = obj.$ref;
@@ -372,6 +373,24 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
372
373
  throw new Error(`Unable to load ${externalRelativeFilePath} from ${cwd}`);
373
374
  });
374
375
  externalFileCache.set(externalFilePath, externalFile);
376
+ // Title should not be overwritten by the title given from the reference
377
+ // Usually Swagger and OpenAPI Schemas have this
378
+ if (externalFile.definitions) {
379
+ for (const definitionName in externalFile.definitions) {
380
+ const definition = externalFile.definitions[definitionName];
381
+ if (!definition.title) {
382
+ definition.title = definitionName;
383
+ }
384
+ }
385
+ }
386
+ if ((_a = externalFile.components) === null || _a === void 0 ? void 0 : _a.schemas) {
387
+ for (const definitionName in externalFile.components.schemas) {
388
+ const definition = externalFile.components.schemas[definitionName];
389
+ if (!definition.title) {
390
+ definition.title = definitionName;
391
+ }
392
+ }
393
+ }
375
394
  }
376
395
  const result = await dereferenceObject(refPath
377
396
  ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-machete",
3
- "version": "0.5.0-alpha-2d2fd0541.0",
3
+ "version": "0.5.1",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "@graphql-mesh/utils": "0.27.0",