Skip to content

Commit

Permalink
add wip test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonluca committed Apr 15, 2024
1 parent d76f98d commit 7b4c2f0
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/specs/nested-pointers/external-from-internal.yaml
@@ -0,0 +1,4 @@
internal1:
$ref: "#/internal2"
internal2:
$ref: "#/external"
112 changes: 112 additions & 0 deletions test/specs/nested-pointers/missing-pointers.spec.ts
@@ -0,0 +1,112 @@
import { describe, it } from "vitest";
import { expect } from "vitest";
import $RefParser from "../../../lib/index.js";
const schema = {
type: "object",
allOf: [
{
description: "REMOVED for better readbility",
},
{
type: "object",
properties: {
payload: {
type: "array",
items: {
allOf: [
{
description: "REMOVED for better readbility",
},
{
type: "object",
properties: {
reservationActionMetaData: {
allOf: [
{
allOf: [
{
type: "object",
properties: {
supplierPriceElements: {
allOf: [
{
description: "REMOVED for better readbility",
},
{
type: "object",
properties: {
purchaseRate: {
allOf: [
{
type: "object",
required: ["amount"],
properties: {
amount: {
type: "number",
},
},
},
{
type: "object",
properties: {
inDetail: {
type: "object",
properties: {
perDate: {
type: "array",
items: {
type: "object",
properties: {
amount: {
$ref: "#/allOf/1/properties/payload/items/allOf/1/properties/reservationActionMetaData/allOf/0/allOf/0/properties/supplierPriceElements/allOf/1/properties/fee/properties/modificationFee/properties/amount",
},
},
},
},
},
},
},
},
],
},
fee: {
type: "object",
properties: {
modificationFee: {
$ref: "#/allOf/1/properties/payload/items/allOf/1/properties/reservationActionMetaData/allOf/0/allOf/0/properties/supplierPriceElements/allOf/1/properties/purchaseRate/allOf/0",
},
},
},
},
},
],
},
},
},
{
description: "REMOVED for better readbility",
},
],
},
{
description: "REMOVED for better readbility",
},
],
},
},
},
],
},
},
},
},
],
};

describe("Schema with nested pointers", () => {
it("should throw an error for missing pointer", async () => {
// todo - get original schema from #338
const bundle = await $RefParser.bundle(schema);
expect(bundle).to.equal(schema);
});
});
103 changes: 103 additions & 0 deletions test/specs/nested-pointers/schema.json
@@ -0,0 +1,103 @@
{
"type": "object",
"allOf": [
{
"description": "REMOVED for better readbility"
},
{
"type": "object",
"properties": {
"payload": {
"type": "array",
"items": {
"allOf": [
{
"description": "REMOVED for better readbility"
},
{
"type": "object",
"properties": {
"reservationActionMetaData": {
"allOf": [
{
"allOf": [
{
"type": "object",
"properties": {
"supplierPriceElements": {
"allOf": [
{
"description": "REMOVED for better readbility"
},
{
"type": "object",
"properties": {
"purchaseRate": {
"allOf": [
{
"type": "object",
"required": [
"amount"
],
"properties": {
"amount": {
"type": "number"
}
}
},
{
"type": "object",
"properties": {
"inDetail": {
"type": "object",
"properties": {
"perDate": {
"type": "array",
"items": {
"type": "object",
"properties": {
"amount": {
"$ref": "#/allOf/1/properties/payload/items/allOf/1/properties/reservationActionMetaData/allOf/0/allOf/0/properties/supplierPriceElements/allOf/1/properties/fee/properties/modificationFee/properties/amount"
}
}
}
}
}
}
}
}
]
},
"fee": {
"type": "object",
"properties": {
"modificationFee": {
"$ref": "#/allOf/1/properties/payload/items/allOf/1/properties/reservationActionMetaData/allOf/0/allOf/0/properties/supplierPriceElements/allOf/1/properties/purchaseRate/allOf/0"
}
}
}
}
}
]
}
}
},
{
"description": "REMOVED for better readbility"
}
]
},
{
"description": "REMOVED for better readbility"
}
]
}
}
}
]
}
}
}
}
]
}

0 comments on commit 7b4c2f0

Please sign in to comment.