Skip to content
Merged
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
62 changes: 62 additions & 0 deletions packages/openapi-code-generator/src/core/openapi-validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,72 @@ describe("core/openapi-validator", () => {
"invalid-spec.yaml",
{
openapi: "3.0.0",
info: {
title: "Invalid Specification",
version: "1.0.0",
},
paths: {
"/something": {
get: {
responses: {},
},
},
},
},
true,
),
).rejects.toThrow(
"Validation failed: -> must NOT have fewer than 1 properties at path '/paths/~1something/get/responses'",
)
})
})

describe.skip("openapi 3.1", () => {
it("should accept a valid specification", async () => {
const validator = await OpenapiValidator.create()
await expect(
validator.validate(
"valid-spec.yaml",
{
openapi: "3.1.0",
info: {
title: "Valid Specification",
version: "1.0.0",
},
paths: {
"/something": {
get: {
responses: {default: {description: "whatever"}},
},
},
},
components: {
schemas: {
Something: {
type: ["object", "null"],
properties: {
name: {type: "string"},
},
},
},
},
},
true,
),
).resolves.toBeUndefined()
})

it("should reject an invalid specification", async () => {
const validator = await OpenapiValidator.create()
await expect(
validator.validate(
"invalid-spec.yaml",
{
openapi: "3.1.0",
info: {
title: "Invalid Specification",
version: "1.0.0",
},
paths: {
"/something": {
get: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module.exports = validate10
module.exports.default = validate10
const schema11 = {
id: "https://spec.openapis.org/oas/3.0/schema/WORK-IN-PROGRESS",
id: "https://spec.openapis.org/oas/3.0/schema/2024-10-18",
$schema: "http://json-schema.org/draft-04/schema#",
description: "The description of OpenAPI v3.0.x Documents",
type: "object",
Expand Down Expand Up @@ -18215,7 +18215,7 @@ function validate10(
data,
{instancePath = "", parentData, parentDataProperty, rootData = data} = {},
) {
/*# sourceURL="https://spec.openapis.org/oas/3.0/schema/WORK-IN-PROGRESS" */
/*# sourceURL="https://spec.openapis.org/oas/3.0/schema/2024-10-18" */
let vErrors = null
let errors = 0
if (errors === 0) {
Expand Down
Loading