-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathexample9.html
61 lines (59 loc) · 1.76 KB
/
example9.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<script src="./load-rapidoc-and-other-common-scripts.js"></script>
</head>
<body>
<rapi-doc id="thedoc"
render-style = "read"
allow-try="false"
allow-authentication = "false"
> </rapi-doc>
<script>
document.addEventListener('readystatechange', (event) => {
let docEl = document.getElementById("thedoc");
let strSpec = `
{
"swagger": "2.0",
"info": {
},
"paths": {
"/JSON": {
"get": {
"summary": "Creating spec from JSON Object",
"description": "This spec is created dynamically from a JSON object For code refer https://github.com/rapi-doc/RapiDoc/blob/master/docs/examples/example9.html",
"produces": [ "application/json"],
"responses": {
"200": {
"description": "A list of pets.",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Pet": {
"type": "object",
"properties": {
"id" : { "type": "integer" },
"name": { "type": "string" },
"tag" : { "type": "string" }
}
}
}
}
`;
let objSpec = JSON.parse(strSpec);
docEl.loadSpec(objSpec);
})
</script>
</body>
</html>