Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8369d91
refactor: simplify the code to serve Hey API requirements
mrlubos Dec 23, 2024
ab68509
0.0.0
mrlubos Dec 25, 2024
c667923
0.0.1
mrlubos Dec 25, 2024
7a54120
Merge pull request #1 from hey-api/feat/download-resolve
mrlubos Dec 25, 2024
8f5531c
chore: update package.json
mrlubos Dec 25, 2024
c9f9b09
Merge pull request #2 from hey-api/chore/package-json
mrlubos Dec 25, 2024
25ba4b3
fix: do not use buffer type as generic
mrlubos Dec 25, 2024
1754059
0.0.2
mrlubos Dec 25, 2024
4743034
Merge pull request #3 from hey-api/fix/buffer-type
mrlubos Dec 25, 2024
b790294
fix: allow passing timeout value to sendRequest
mrlubos Feb 3, 2025
e5c19c0
0.0.3
mrlubos Feb 3, 2025
1a3f1c0
Merge pull request #4 from hey-api/fix/request-timeout
mrlubos Feb 3, 2025
f153d25
chore: sync package.json version with npm
mrlubos Feb 3, 2025
6860977
Merge pull request #5 from hey-api/chore/package-json-version
mrlubos Feb 3, 2025
6eb665e
fix: correctly resolve json input
mrlubos Mar 14, 2025
a92ca73
1.0.3
mrlubos Mar 14, 2025
92dbaac
Merge pull request #6 from hey-api/fix/resolve-json
mrlubos Mar 14, 2025
5e5ccf1
fix: allow passing fetch options to request
mrlubos Mar 31, 2025
dbde5d1
Merge pull request #7 from hey-api/fix/fetch-options
mrlubos Mar 31, 2025
f0a4310
fix: extended equality check
mrlubos Apr 23, 2025
9ba4565
Merge pull request #8 from hey-api/fix/extended-ref-equality
mrlubos Apr 23, 2025
9e09d3b
fix: parsing of schema resolved from URL when HTTP status is 200
mblumenstingl-n11 May 5, 2025
7b37bdf
Merge pull request #9 from mblumenstingl-n11/fix/parsing-of-schema-re…
mrlubos May 13, 2025
4e36205
fix: improve inventory check for pointers and add tests for multiple …
carson2222 Aug 27, 2025
f05ba07
Merge pull request #10 from hey-api/fix/improve-ref-pointer-inventory…
carson2222 Aug 27, 2025
50c6ee3
fix: inline internal JSON Pointer refs under #/paths/ for OpenAPI bun…
carson2222 Aug 29, 2025
5fb8e24
chore: add test case
carson2222 Aug 29, 2025
a549ba5
chore: code cleanup
carson2222 Sep 1, 2025
d6f8438
chore: code cleanup
carson2222 Sep 1, 2025
5a801bf
Merge pull request #11 from hey-api/fix/internal-json-pointer-bundling
carson2222 Sep 1, 2025
b3ba1d9
feat: enhance performance tracking in JSON reference bundling
max-scopp Sep 2, 2025
9eea073
chore: disable debug logging for bundling process
max-scopp Sep 2, 2025
9937043
fix: enhance bundling and dereferencing logic for external $ref
carson2222 Sep 2, 2025
d4ec386
Merge branch 'main' into fix--update-external-ref-handling
carson2222 Sep 2, 2025
cbf25e7
Merge commit 'refs/pull/12/head' of https://github.com/hey-api/json-s…
carson2222 Sep 3, 2025
0f7f409
Merge pull request #13 from hey-api/fix--update-external-ref-handling
carson2222 Sep 3, 2025
4674566
feat: implement bundling of multiple schemas with enhanced prefix han…
carson2222 Sep 8, 2025
46315f8
chore: enhance schema merging logic to prioritize OpenAPI and Swagger…
carson2222 Sep 8, 2025
e97ef5c
chore: update version to 1.2.0 in package.json
carson2222 Sep 10, 2025
f5f2c67
docs: update README to reflect package name change and new features i…
carson2222 Sep 10, 2025
e043602
Merge pull request #14 from hey-api/feat--multiple-input-support
carson2222 Sep 10, 2025
e58322a
fix: do not overwrite in circular self references
mrlubos Oct 22, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions lib/__tests__/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@ describe("bundle", () => {
const pathOrUrlOrSchema = path.resolve("lib", "__tests__", "spec", "multiple-refs.json");
const schema = (await refParser.bundle({ pathOrUrlOrSchema })) as any;

// First reference should be fully resolved (no $ref)
expect(schema.paths["/test1/{pathId}"].get.parameters[0].name).toBe("pathId");
expect(schema.paths["/test1/{pathId}"].get.parameters[0].schema.type).toBe("string");
expect(schema.paths["/test1/{pathId}"].get.parameters[0].schema.format).toBe("uuid");
expect(schema.paths["/test1/{pathId}"].get.parameters[0].$ref).toBeUndefined();

// Second reference should be remapped to point to the first reference
expect(schema.paths["/test2/{pathId}"].get.parameters[0].$ref).toBe(
"#/paths/~1test1~1%7BpathId%7D/get/parameters/0",
);

// Both should effectively resolve to the same data
// Both parameters should now be $ref to the same internal definition
const firstParam = schema.paths["/test1/{pathId}"].get.parameters[0];
const secondParam = schema.paths["/test2/{pathId}"].get.parameters[0];

// The second parameter should resolve to the same data as the first
expect(secondParam.$ref).toBeDefined();
expect(firstParam).toEqual({
// The $ref should match the output structure in file_context_0
expect(firstParam.$ref).toBe("#/components/parameters/path-parameter_pathId");
expect(secondParam.$ref).toBe("#/components/parameters/path-parameter_pathId");

// The referenced parameter should exist and match the expected structure
expect(schema.components).toBeDefined();
expect(schema.components.parameters).toBeDefined();
expect(schema.components.parameters["path-parameter_pathId"]).toEqual({
name: "pathId",
in: "path",
required: true,
Expand Down
9 changes: 5 additions & 4 deletions lib/__tests__/pointer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe("pointer", () => {
const refParser = new $RefParser();
const pathOrUrlOrSchema = path.resolve("lib", "__tests__", "spec", "openapi-paths-ref.json");
const schema = (await refParser.bundle({ pathOrUrlOrSchema })) as any;
console.log(JSON.stringify(schema, null, 2));

// The GET endpoint should have its schema defined inline
const getSchema = schema.paths["/foo"].get.responses["200"].content["application/json"].schema;
Expand All @@ -16,11 +17,11 @@ describe("pointer", () => {

// The POST endpoint should have its schema inlined (copied) instead of a $ref
const postSchema = schema.paths["/foo"].post.responses["200"].content["application/json"].schema;
expect(postSchema.$ref).toBeUndefined();
expect(postSchema.type).toBe("object");
expect(postSchema.properties.bar.type).toBe("string");
expect(postSchema.$ref).toBe("#/paths/~1foo/get/responses/200/content/application~1json/schema");
expect(postSchema.type).toBeUndefined();
expect(postSchema.properties?.bar?.type).toBeUndefined();

// Both schemas should be identical objects
expect(postSchema).toEqual(getSchema);
expect(postSchema).not.toBe(getSchema);
});
});
4 changes: 2 additions & 2 deletions lib/__tests__/spec/multiple-refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"summary": "First endpoint using the same pathId schema",
"parameters": [
{
"$ref": "path-parameter.json#/pathId"
"$ref": "path-parameter.json#/components/parameters/pathId"
}
],
"responses": {
Expand All @@ -20,7 +20,7 @@
"summary": "Second endpoint using the same pathId schema",
"parameters": [
{
"$ref": "path-parameter.json#/pathId"
"$ref": "path-parameter.json#/components/parameters/pathId"
}
],
"responses": {
Expand Down
20 changes: 12 additions & 8 deletions lib/__tests__/spec/path-parameter.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"pathId": {
"name": "pathId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid",
"description": "Unique identifier for the path"
"components": {
"parameters": {
"pathId": {
"name": "pathId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid",
"description": "Unique identifier for the path"
}
}
}
}
}
Loading