fix: set yaml parser load option to JSON_SCHEMA (#8023)

This commit is contained in:
Tim Lai
2022-05-12 15:51:38 -07:00
committed by GitHub
parent abeb168696
commit 41f84aad05
4 changed files with 53 additions and 4 deletions

View File

@@ -0,0 +1,26 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Native date formats in YAML
paths:
/foo:
get:
description: Has date without quotes
responses:
'200':
description: Ok
content:
application/json:
schema:
type: object
properties:
without-quotes:
type: string
format: date
example: 1999-11-31
with-quotes:
type: string
format: date
example: "1999-12-31"

View File

@@ -0,0 +1,23 @@
/**
* @prettier
*/
describe("Parse YAML as YAML@1.2 with json_schema for all JSON-supported types", () => {
it("should have date string even without quotes", () => {
cy.visit("/?url=/documents/features/spec-parse-to-json.yaml")
.get("#operations-default-get_foo")
.click()
// Responses -> example value tab
.get(".language-json > :nth-child(3)")
.should("have.text", "\"without-quotes\"")
.get(".language-json > :nth-child(5)")
.should("have.text", "\"1999-11-31\"")
// Responses -> schema tab
.get(".model-example > .tab > :nth-child(2)")
.click()
.get(":nth-child(1) > :nth-child(2) > .model > :nth-child(1) > .prop > .property") // first element, without-quotes
.should("have.text", "example: 1999-11-31")
.get(":nth-child(2) > :nth-child(2) > .model > :nth-child(1) > .prop > .property") // second element, with quotes
.should("have.text", "example: 1999-12-31")
})
})