Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/openapi/tests/assets/nested-1/nested-components.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
components:
schemas:
ThingKey:
type: object
properties:
userId:
type: integer
thingId:
type: integer
required:
- userId
- thingId

ThingData:
type: object
properties:
lastSeen:
type: string
format: date-time
value:
type: integer

Thing:
type: object
allOf:
- $ref: "#/components/schemas/ThingKey"
- $ref: "#/components/schemas/ThingData"

requestBodies:
GetOneThingRequest:
content:
application/json:
schema:
$ref: "#/components/schemas/ThingKey"

responses:
GetOneThingResponse:
description: one thing
content:
application/json:
schema:
$ref: "#/components/schemas/Thing"
15 changes: 15 additions & 0 deletions packages/openapi/tests/assets/nested-api-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
openapi: 3.0.3

info:
title: pork
version: 0.0.0

paths:
/get:
post:
operationId: getOneThing
requestBody:
$ref: "nested-1/nested-components.yml#/components/requestBodies/GetOneThingRequest"
responses:
200:
$ref: "nested-1/nested-components.yml#/components/responses/GetOneThingResponse"
7 changes: 7 additions & 0 deletions packages/openapi/tests/openapi-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ describe("openapi-parser", () => {
expect(models[3]).toHaveProperty("name.text", "ThingNested");
});

test("should properly resolve nested references part 2: the revengeance", async () => {
const fileName = "nested-api-1.yml";
const schema = loadSpec(fileName);
const { models } = await parseOpenApi(schema, { cwd: getAssetsPath() });
expect(models).toHaveLength(4);
})

});

});