Skip to content

Commit

Permalink
fix #70: bump json-crawl
Browse files Browse the repository at this point in the history
  • Loading branch information
udamir committed Jan 5, 2024
1 parent a5550a0 commit 62d509c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allof-merge",
"version": "0.6.3",
"version": "0.6.4",
"description": "Simplify JsonSchema/Openapi by combining allOf safely",
"module": "dist/index.mjs",
"main": "dist/index.cjs",
Expand Down Expand Up @@ -85,6 +85,6 @@
"collectCoverage": true
},
"dependencies": {
"json-crawl": "^0.5.1"
"json-crawl": "^0.5.2"
}
}
4 changes: 2 additions & 2 deletions src/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const selectMergeRules = (data: unknown): MergeRules => {
}


export const merge = (value: any, options?: MergeOptions) => {
export const merge = (value: unknown, options?: MergeOptions) => {
const rules: MergeRules = options?.rules ?? selectMergeRules(value)
return syncClone(value, allOfResolverHook(options), { rules })
}
Expand Down Expand Up @@ -90,7 +90,7 @@ export const allOfResolverHook = (options?: MergeOptions): SyncCloneHook<{}> =>

const { allOf, ...sibling } = value

const _allOf: any[] = []
const _allOf: unknown[] = []
// remove allOf from scheam if is wrong type
if (Array.isArray(allOf)) {
_allOf.push(...allOf)
Expand Down
8 changes: 4 additions & 4 deletions src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type JsonPath, isObject } from "json-crawl"
import { buildPointer, isRefNode, parseRef, resolvePointer } from "./utils"
import type { AllOfRef, NormalizeResponse } from "./types"

export const normalizeAllOfItems = (allOfItems: any[], jsonPath: JsonPath, source: any, allOfRefs: AllOfRef[]): NormalizeResponse => {
export const normalizeAllOfItems = (allOfItems: unknown[], jsonPath: JsonPath, source: unknown, allOfRefs: AllOfRef[]): NormalizeResponse => {
const resolvedAllOfItems = []
const pointer = buildPointer(jsonPath)
const brokenRefs: string[] = []
Expand Down Expand Up @@ -56,10 +56,10 @@ export const normalizeAllOfItems = (allOfItems: any[], jsonPath: JsonPath, sourc
return { allOfItems: items, brokenRefs }
}

const flattenAllOf = (items: any[]): any[] => {
const flattenAllOf = (items: unknown[]): unknown[] => {
// allOf: [{ allOf: [a,b], c }] => allOf: [a, b, c]

const result: any[] = []
const result: unknown[] = []
for (const item of items) {
if (!isObject(item)) {
// error, object expected
Expand All @@ -71,7 +71,7 @@ const flattenAllOf = (items: any[]): any[] => {
result.push(item)
} else {
const { allOf, ...sibling } = item
const allOfItems = Object.keys(sibling).length ? [...allOf, sibling] : allOf as any[]
const allOfItems = Object.keys(sibling).length ? [...allOf, sibling] : allOf
result.push(...flattenAllOf(allOfItems))
}
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2482,10 +2482,10 @@ jsesc@^2.5.1:
resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz"
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==

json-crawl@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json-crawl/-/json-crawl-0.5.1.tgz#1dcd753ee1bcbebe15934f350bb577e422e5c16b"
integrity sha512-guQYl5NFDUC6XtJvlMb80rYTJ0LhY9lLlDpL6idDwSGldpGayWBzsstK7BlmULXM/WsT0jI+skiilwiRb904wA==
json-crawl@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/json-crawl/-/json-crawl-0.5.2.tgz#5e4d3d40f1bb8c484bd451f5198d9eca2136f473"
integrity sha512-psBnZ5fdZQZJau/1J+pAjnpEY1JzL2AQ7am8TBf/eyDjsMovAaGlZUxcEvOVBuZ92920ACiN+OD0YOv+hb7b0w==

json-parse-even-better-errors@^2.3.0:
version "2.3.1"
Expand Down

0 comments on commit 62d509c

Please sign in to comment.