-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(json-schema-2020-12): expand deeply all Schema Objects and comple…
…x keywords (#9581) Refs #9508 Supersedes #9510 Co-authored-by: Julien Bourges <julien.bourges@actility.com>
- Loading branch information
Showing
10 changed files
with
230 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/e2e-cypress/e2e/features/plugins/json-schema-2020-12/expansion.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("JSON Schema 2020-12 complex keywords expansion", () => { | ||
it("should deeply expand all Schemas and complex keywords", () => { | ||
cy.visit("/pages/json-schema-2020-12-expansion/").then( | ||
() => { | ||
cy.get(".json-schema-2020-12-accordion") | ||
.find(".json-schema-2020-12-accordion__icon--collapsed") | ||
.should("not.exist") | ||
cy.contains("anyOf1-p1-p2-p1").should("exist") | ||
cy.contains("oneOf1-p1-p2-p1").should("exist") | ||
cy.contains("Prefix items").should("exist") | ||
cy.contains("exampleDef").should("exist") | ||
cy.contains("https://json-schema.org/draft/2020-12/vocab/core").should("exist") | ||
} | ||
) | ||
}) | ||
}) |
100 changes: 100 additions & 0 deletions
100
test/e2e-cypress/static/pages/json-schema-2020-12-expansion/expansion.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
openapi: "3.1.0" | ||
info: | ||
version: "0.0.1" | ||
title: "Swagger UI Webpack Setup" | ||
description: "Demonstrates Swagger UI" | ||
components: | ||
schemas: {} | ||
security: [] | ||
paths: | ||
/pets: | ||
get: | ||
responses: | ||
200: | ||
description: "OK" | ||
content: | ||
application/json: | ||
schema: | ||
$vocabulary: | ||
https://json-schema.org/draft/2020-12/vocab/core: true | ||
https://json-schema.org/draft/2020-12/vocab/applicator: true | ||
https://json-schema.org/draft/2020-12/vocab/validation: true | ||
https://json-schema.org/draft/2020-12/vocab/meta-data: true | ||
https://json-schema.org/draft/2020-12/vocab/format-annotation: false | ||
https://example.com/my-custom-vocab: true | ||
$defs: | ||
exampleDef: | ||
type: string | ||
allOf: | ||
- oneOf: | ||
- type: object | ||
properties: | ||
oneOf1-p1: | ||
type: object | ||
properties: | ||
oneOf1-p1-p1: | ||
type: string | ||
oneOf1-p1-p2: | ||
type: object | ||
properties: | ||
oneOf1-p1-p2-p1: | ||
type: string | ||
oneOf1-p2: | ||
type: string | ||
- type: object | ||
properties: | ||
oneOf2-p1: | ||
type: string | ||
oneOf2-p2: | ||
type: string | ||
- anyOf: | ||
- type: object | ||
properties: | ||
anyOf1-p1: | ||
type: object | ||
properties: | ||
anyOf1-p1-p1: | ||
type: string | ||
anyOf1-p1-p2: | ||
type: object | ||
properties: | ||
anyOf1-p1-p2-p1: | ||
type: string | ||
anyOf1-p2: | ||
type: string | ||
- type: object | ||
properties: | ||
anyOf2-p1: | ||
type: object | ||
properties: | ||
anyOf2-p1-p1: | ||
type: string | ||
anyOf2-p2: | ||
type: string | ||
- type: object | ||
properties: | ||
p1: | ||
type: object | ||
properties: | ||
p1-p1: | ||
type: string | ||
p1-p2: | ||
type: object | ||
properties: | ||
p1-p2-p1: | ||
type: string | ||
dependentSchemas: | ||
p1-p1: | ||
properties: | ||
p3: | ||
type: array | ||
prefixItems: | ||
- type: string | ||
enum: [a, b, c] | ||
required: [p3] | ||
p2: | ||
type: string | ||
prefixItems: | ||
- type: string | ||
enum: [a, b, c] | ||
tags: [] |
65 changes: 65 additions & 0 deletions
65
test/e2e-cypress/static/pages/json-schema-2020-12-expansion/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!-- HTML for dev server --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Swagger UI</title> | ||
<link rel="stylesheet" type="text/css" href="/swagger-ui.css"> | ||
<style> | ||
html { | ||
box-sizing: border-box; | ||
overflow: -moz-scrollbars-vertical; | ||
overflow-y: scroll; | ||
} | ||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
body { | ||
margin:0; | ||
background: #fafafa; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="swagger-ui"></div> | ||
|
||
<script src="/swagger-ui-bundle.js" charset="UTF-8"> </script> | ||
<script src="/swagger-ui-standalone-preset.js" charset="UTF-8"> </script> | ||
<script> | ||
window.onload = function() { | ||
window["SwaggerUIBundle"] = window["swagger-ui-bundle"] | ||
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"] | ||
// Build a system | ||
const ui = SwaggerUIBundle({ | ||
url: "./expansion.yaml", | ||
dom_id: '#swagger-ui', | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
plugins: [], | ||
layout: "StandaloneLayout", | ||
docExpansion: "full", | ||
defaultModelExpandDepth: 100, | ||
defaultModelRendering: "model", | ||
onComplete: () => { | ||
if(window.completeCount) { | ||
window.completeCount++ | ||
} else { | ||
window.completeCount = 1 | ||
} | ||
}, | ||
queryConfigEnabled: true, | ||
}) | ||
|
||
window.ui = ui | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |