UNPKG

30.2 kBHTMLView Raw
1<!doctype html><html><head><meta charset="utf-8"/><script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script><script>const spec = {
2 "openapi": "3.0.0",
3 "info": {
4 "title": "Providing Examples",
5 "description": "Providing Examples",
6 "version": "1.0.0"
7 },
8 "paths": {
9 "/multiple-examples-in-request-parameters/{path-param-1}/{path-param-2}": {
10 "get": {
11 "tags": [
12 "Providing Examples"
13 ],
14 "parameters": [
15 {
16 "name": "path-param-1",
17 "in": "path",
18 "schema": {
19 "type": "string",
20 "default": "p1-opt-2"
21 },
22 "examples": {
23 "example1": {
24 "value": "p1-opt-1"
25 },
26 "example2": {
27 "value": "p1-opt-2"
28 }
29 }
30 },
31 {
32 "name": "path-param-2",
33 "in": "path",
34 "schema": {
35 "type": "string"
36 },
37 "examples": {
38 "example1": {
39 "value": "p2-opt-1"
40 },
41 "example2": {
42 "value": "p2-opt-2"
43 }
44 }
45 },
46 {
47 "name": "age",
48 "description": "Single Example",
49 "in": "query",
50 "schema": {
51 "type": "number"
52 },
53 "example": 24
54 },
55 {
56 "name": "country-code",
57 "description": "Multiple examples _(Notice `us` do not have a summary)_",
58 "in": "query",
59 "schema": {
60 "type": "string",
61 "default": " "
62 },
63 "examples": {
64 "example1": {
65 "value": "uk",
66 "summary": "United Kingdom"
67 },
68 "example2": {
69 "value": "us"
70 },
71 "example3": {
72 "value": "ch",
73 "summary": "China"
74 }
75 }
76 },
77 {
78 "name": "marital-status",
79 "in": "query",
80 "schema": {
81 "type": "string",
82 "default": "unmarried"
83 },
84 "examples": {
85 "example1": {
86 "value": "married"
87 },
88 "example2": {
89 "value": "unmarried"
90 },
91 "example3": {
92 "value": "widowed"
93 }
94 }
95 },
96 {
97 "name": "luckyNumbers",
98 "in": "query",
99 "schema": {
100 "type": "array",
101 "items": {
102 "type": "number"
103 },
104 "minItems": 4,
105 "maxItems": 4,
106 "examples": [
107 "",
108 " ",
109 [
110 10
111 ],
112 [
113 10,
114 20,
115 30,
116 40
117 ]
118 ]
119 }
120 }
121 ]
122 }
123 },
124 "/multiple-examples-by-response-type": {
125 "get": {
126 "description": "Multiple Examples provide for each media-type (`application/json` or `application/json`)",
127 "tags": [
128 "Providing Examples"
129 ],
130 "responses": {
131 "200": {
132 "description": "Successful operation",
133 "content": {
134 "application/json": {
135 "schema": {
136 "type": "object",
137 "properties": {
138 "age": {
139 "description": "Person Age",
140 "type": "integer"
141 },
142 "fullName": {
143 "description": "Person Full name",
144 "type": "object",
145 "properties": {
146 "firstName": {
147 "description": "First name",
148 "type": "string"
149 },
150 "lastName": {
151 "description": "Last name",
152 "type": "string"
153 }
154 }
155 }
156 }
157 },
158 "examples": {
159 "valid-json": {
160 "summary": "Example with Valid JSON String",
161 "description": "If valid JSON is provided in the example, It will be displayed in JSON tree form. Allowing copy/expand/collapse functionality",
162 "value": "{\n \"person\": {\n \"fullName\": {\n \"firstName\": \"Mickey\",\n \"lastName\": \"Mouse\"\n },\n \"age\": \"9\"\n }\n}\n"
163 },
164 "invalid-json": {
165 "summary": "Example with Invalid JSON String",
166 "description": "Invalid JSON is displayed in text-area as is",
167 "value": "{\n person: {\n fullName: {\n firstName: Donald,\n lastName: Duck\n },\n age: 10\n }\n}\n"
168 },
169 "as-object": {
170 "summary": "Example specified as object",
171 "value": {
172 "fullName": {
173 "firstName": "Donald",
174 "lastName": "Duck"
175 },
176 "age": 10
177 }
178 }
179 }
180 },
181 "application/xml": {
182 "schema": {
183 "type": "object",
184 "properties": {
185 "age": {
186 "description": "Person Age",
187 "type": "integer"
188 },
189 "fullName": {
190 "description": "Person Full name",
191 "type": "object",
192 "properties": {
193 "firstName": {
194 "description": "First name",
195 "type": "string"
196 },
197 "lastName": {
198 "description": "Last name",
199 "type": "string"
200 }
201 }
202 }
203 }
204 },
205 "examples": {
206 "example-1": {
207 "description": "Exmple 1 Description",
208 "value": "<root>\n <person>\n <fullName>\n <firstName> Mickey </firstName>\n <lastName> Mouse </lastName>\n </fullName>\n <age> 9 </age>\n </person>\n</root>\n"
209 }
210 }
211 }
212 }
213 }
214 }
215 }
216 },
217 "/single-example-by-response-type": {
218 "get": {
219 "summary": "Single Example at schema Level",
220 "tags": [
221 "Providing Examples"
222 ],
223 "responses": {
224 "200": {
225 "description": "Successful operation",
226 "content": {
227 "application/json": {
228 "schema": {
229 "type": "object",
230 "properties": {
231 "age": {
232 "description": "Person Age",
233 "type": "integer"
234 },
235 "fullName": {
236 "description": "Person Full name",
237 "type": "object",
238 "properties": {
239 "firstName": {
240 "description": "First name",
241 "type": "string"
242 },
243 "lastName": {
244 "description": "Last name",
245 "type": "string"
246 }
247 }
248 }
249 }
250 },
251 "example": "{\n age: 10,\n fullName: {\n firstName: Donald,\n lastName: Duck\n }\n}\n"
252 }
253 }
254 }
255 }
256 }
257 },
258 "/example-with-array-1": {
259 "get": {
260 "summary": "Single Example at schema Level",
261 "tags": [
262 "Providing Examples"
263 ],
264 "responses": {
265 "200": {
266 "description": "Successful operation",
267 "content": {
268 "application/json": {
269 "schema": {
270 "$ref": "#/components/schemas/ArrayOfInt-1"
271 }
272 }
273 }
274 }
275 }
276 }
277 },
278 "/example-with-array-2": {
279 "get": {
280 "summary": "Single Example at schema Level",
281 "tags": [
282 "Providing Examples"
283 ],
284 "responses": {
285 "200": {
286 "description": "Successful operation",
287 "content": {
288 "application/json": {
289 "schema": {
290 "$ref": "#/components/schemas/ArrayOfInt-2"
291 }
292 }
293 }
294 }
295 }
296 }
297 },
298 "/object-example-for-a-schema": {
299 "get": {
300 "summary": "Single example having invalid JSON, under a Schema",
301 "tags": [
302 "Providing Examples"
303 ],
304 "responses": {
305 "200": {
306 "description": "Successful operation",
307 "content": {
308 "application/json": {
309 "schema": {
310 "type": "object",
311 "properties": {
312 "age": {
313 "description": "Person Age",
314 "type": "integer"
315 },
316 "fullName": {
317 "description": "Person Full name",
318 "type": "object",
319 "properties": {
320 "firstName": {
321 "description": "First name",
322 "type": "string"
323 },
324 "lastName": {
325 "description": "Last name",
326 "type": "string"
327 }
328 }
329 }
330 },
331 "example": "{\n person: {\n fullName: {\n firstName: Donald,\n lastName: Duck\n },\n age: 10\n }\n}\n"
332 }
333 }
334 }
335 }
336 }
337 }
338 },
339 "/array-example-for-a-schema": {
340 "get": {
341 "summary": "Single Example of Type Array Under a Schema",
342 "tags": [
343 "Providing Examples"
344 ],
345 "responses": {
346 "200": {
347 "description": "An array of currency codes",
348 "content": {
349 "application/json": {
350 "schema": {
351 "$ref": "#/components/schemas/currencies"
352 }
353 }
354 }
355 }
356 }
357 }
358 },
359 "/example-with-simple-object": {
360 "get": {
361 "summary": "Single Example of Type Array Under a Schema",
362 "tags": [
363 "Providing Examples"
364 ],
365 "responses": {
366 "200": {
367 "description": "An array of currency codes",
368 "content": {
369 "application/json": {
370 "schema": {
371 "$ref": "#/components/schemas/PersonObject"
372 }
373 }
374 }
375 }
376 }
377 }
378 },
379 "/per-field-example-with-root-as-object": {
380 "get": {
381 "summary": "Root node of the example is an object. and the object is constituted using field level example",
382 "tags": [
383 "Providing Examples"
384 ],
385 "responses": {
386 "200": {
387 "description": "Successful operation",
388 "content": {
389 "application/json": {
390 "schema": {
391 "type": "object",
392 "properties": {
393 "age": {
394 "description": "Person Age",
395 "type": "integer",
396 "example": 8
397 },
398 "fullName": {
399 "description": "Person Full name",
400 "type": "object",
401 "properties": {
402 "firstName": {
403 "description": "First name",
404 "type": "string",
405 "example": "Daisy"
406 },
407 "lastName": {
408 "description": "Last name",
409 "type": "string",
410 "example": "Duck"
411 }
412 }
413 },
414 "dependents": {
415 "type": "array",
416 "items": {
417 "type": "object",
418 "properties": {
419 "dependentName": {
420 "type": "string"
421 },
422 "relation": {
423 "type": "string"
424 },
425 "age": {
426 "type": "number"
427 }
428 }
429 }
430 }
431 }
432 }
433 }
434 }
435 }
436 }
437 }
438 },
439 "/per-field-example-with-root-as-array": {
440 "get": {
441 "summary": "Root node of the example is an array. and the object is constituted using field level example",
442 "tags": [
443 "Providing Examples"
444 ],
445 "responses": {
446 "200": {
447 "description": "Successful operation",
448 "content": {
449 "application/json": {
450 "schema": {
451 "type": "array",
452 "items": {
453 "type": "object",
454 "properties": {
455 "dependentName": {
456 "type": "string"
457 },
458 "relation": {
459 "type": "string"
460 },
461 "age": {
462 "type": "number"
463 }
464 },
465 "example": {
466 "dependentName": "Natasha",
467 "relation": "wife",
468 "age": 28
469 }
470 }
471 }
472 }
473 }
474 }
475 }
476 }
477 },
478 "/example-with-refs": {
479 "get": {
480 "description": "When a Schema definition is `provided` as a ref \n(provide the example at schema-level)\n",
481 "tags": [
482 "Providing Examples"
483 ],
484 "responses": {
485 "200": {
486 "description": "Successful operation",
487 "content": {
488 "application/json": {
489 "schema": {
490 "type": "array",
491 "items": {
492 "$ref": "#/components/schemas/cost"
493 }
494 },
495 "examples": {
496 "USD": {
497 "description": "Cost in `US Dollars`",
498 "value": "{\n amount: 10,\n currency: USD\n}\n"
499 },
500 "INR": {
501 "description": "Cost in `Indian Rupees`",
502 "value": "{\n amount: 700,\n currency: INR\n}\n"
503 }
504 }
505 }
506 }
507 }
508 }
509 }
510 },
511 "/example-with-request-body-as-string": {
512 "post": {
513 "summary": "Test RequestBody as string",
514 "requestBody": {
515 "content": {
516 "text/plain": {
517 "schema": {
518 "type": "string"
519 },
520 "examples": [
521 "one",
522 "two"
523 ]
524 }
525 }
526 }
527 }
528 },
529 "/example-with-request-body-as-integer": {
530 "post": {
531 "summary": "Test RequestBody as integer",
532 "requestBody": {
533 "content": {
534 "text/plain": {
535 "schema": {
536 "type": "integer"
537 },
538 "examples": [
539 1,
540 2
541 ]
542 }
543 }
544 }
545 }
546 },
547 "/example-with-request-body-as-array-of-string": {
548 "post": {
549 "summary": "Test RequestBody as array of string",
550 "requestBody": {
551 "content": {
552 "application/json": {
553 "schema": {
554 "type": "array",
555 "items": {
556 "type": "string"
557 }
558 }
559 }
560 }
561 }
562 }
563 },
564 "/multiple-example-in-request-body": {
565 "post": {
566 "summary": "Request body with multiple examples",
567 "tags": [
568 "Providing Examples"
569 ],
570 "requestBody": {
571 "description": "Request body containing **multiple** examples",
572 "required": true,
573 "content": {
574 "application/json": {
575 "schema": {
576 "type": "array",
577 "items": {
578 "$ref": "#/components/schemas/cost"
579 }
580 },
581 "examples": {
582 "USD": {
583 "description": "Cost in `US Dollars`",
584 "value": "{\n amount: 10,\n currency: USD\n}\n"
585 },
586 "INR": {
587 "description": "Cost in `Indian Rupees`",
588 "value": "{\n amount: 700,\n currency: INR\n}\n"
589 }
590 }
591 }
592 }
593 }
594 }
595 },
596 "/object-containg-array-property-with-example": {
597 "get": {
598 "summary": "Object schema with array type property containing example",
599 "tags": [
600 "Providing Examples"
601 ],
602 "responses": {
603 "200": {
604 "description": "Object with array type property containing example",
605 "content": {
606 "application/json": {
607 "schema": {
608 "$ref": "#/components/schemas/ObjectWithArrayPropExample"
609 }
610 }
611 }
612 }
613 }
614 }
615 },
616 "/examples-anyOf": {
617 "get": {
618 "tags": [
619 "Providing Examples"
620 ],
621 "summary": "AnyOf schemas with examples as part of the subschema",
622 "responses": {
623 "200": {
624 "description": "AnyOf schemas with examples as part of the subschema",
625 "content": {
626 "application/problem+json": {
627 "schema": {
628 "anyOf": [
629 {
630 "title": "AnyOf example 1",
631 "description": "First example",
632 "type": "object",
633 "properties": {
634 "foo": {
635 "type": "string"
636 },
637 "bar": {
638 "type": "integer"
639 }
640 },
641 "example": {
642 "foo": "foo",
643 "bar": 42
644 }
645 },
646 {
647 "title": "Second anyOf",
648 "description": "Another example",
649 "type": "array",
650 "items": {
651 "type": "object",
652 "properties": {
653 "foo": {
654 "type": "string"
655 },
656 "quux": {
657 "type": "array",
658 "items": {
659 "type": "number"
660 }
661 }
662 }
663 },
664 "example": {
665 "foo": "foo",
666 "quux": [
667 42,
668 24
669 ]
670 }
671 },
672 {
673 "title": "No example defined",
674 "type": "array",
675 "items": {
676 "type": "object",
677 "properties": {
678 "foo": {
679 "type": "string"
680 },
681 "quux": {
682 "type": "array",
683 "items": {
684 "type": "number"
685 }
686 }
687 }
688 }
689 }
690 ]
691 }
692 }
693 }
694 }
695 }
696 }
697 },
698 "/examples-anyOf-with-general-properties": {
699 "get": {
700 "tags": [
701 "Providing Examples"
702 ],
703 "summary": "AnyOf schemas with general properties",
704 "responses": {
705 "200": {
706 "description": "AnyOf schemas with general properties",
707 "content": {
708 "application/problem+json": {
709 "schema": {
710 "title": "A composed object",
711 "type": "object",
712 "properties": {
713 "common": {
714 "type": "string"
715 },
716 "other": {
717 "type": "number"
718 }
719 },
720 "anyOf": [
721 {
722 "title": "Schema 1",
723 "type": "object",
724 "properties": {
725 "foo": {
726 "type": "string"
727 },
728 "bar": {
729 "type": "integer"
730 }
731 },
732 "example": {
733 "foo": "foo",
734 "bar": 42
735 }
736 },
737 {
738 "title": "Second schema",
739 "type": "object",
740 "properties": {
741 "baz": {
742 "type": "string",
743 "format": "url"
744 }
745 }
746 }
747 ]
748 }
749 }
750 }
751 }
752 }
753 }
754 },
755 "/examples-oneOf": {
756 "get": {
757 "tags": [
758 "Providing Examples"
759 ],
760 "summary": "OneOf schema with examples as part of the subschema",
761 "responses": {
762 "200": {
763 "description": "OneOf schema with examples as part of the subschema",
764 "content": {
765 "application/problem+json": {
766 "schema": {
767 "oneOf": [
768 {
769 "title": "Schema 1",
770 "type": "object",
771 "properties": {
772 "foo": {
773 "type": "string"
774 },
775 "bar": {
776 "type": "integer"
777 }
778 },
779 "example": {
780 "foo": "foo",
781 "bar": 42
782 }
783 },
784 {
785 "title": "Second schema",
786 "type": "object",
787 "properties": {
788 "baz": {
789 "type": "string",
790 "format": "url"
791 }
792 }
793 }
794 ]
795 }
796 }
797 }
798 }
799 }
800 }
801 },
802 "/examples-allOf": {
803 "get": {
804 "tags": [
805 "Providing Examples"
806 ],
807 "summary": "AllOf schemas with examples as part of the subschema",
808 "responses": {
809 "200": {
810 "description": "AllOf schemas with examples as part of the subschema",
811 "content": {
812 "application/problem+json": {
813 "schema": {
814 "allOf": [
815 {
816 "title": "Schema 1",
817 "type": "object",
818 "properties": {
819 "foo": {
820 "type": "string"
821 },
822 "bar": {
823 "type": "integer"
824 }
825 }
826 },
827 {
828 "title": "Second schema",
829 "type": "object",
830 "properties": {
831 "baz": {
832 "type": "string",
833 "format": "url"
834 }
835 }
836 }
837 ]
838 }
839 }
840 }
841 }
842 }
843 }
844 },
845 "/examples-allOf-anyOf": {
846 "get": {
847 "tags": [
848 "Providing Examples"
849 ],
850 "summary": "Combination of allOf & nested anyOf schemas",
851 "responses": {
852 "200": {
853 "description": "Combination of allOf & nested anyOf schemas",
854 "content": {
855 "application/problem+json": {
856 "schema": {
857 "allOf": [
858 {
859 "title": "Schema 1",
860 "type": "object",
861 "properties": {
862 "foo": {
863 "type": "string"
864 },
865 "bar": {
866 "type": "integer"
867 }
868 }
869 },
870 {
871 "title": "Second schema",
872 "anyOf": [
873 {
874 "type": "object",
875 "properties": {
876 "baz": {
877 "type": "string",
878 "format": "url"
879 }
880 }
881 },
882 {
883 "type": "object",
884 "properties": {
885 "foobar": {
886 "type": "string"
887 }
888 }
889 }
890 ]
891 }
892 ]
893 }
894 }
895 }
896 }
897 }
898 }
899 }
900 },
901 "components": {
902 "schemas": {
903 "cost": {
904 "type": "object",
905 "properties": {
906 "amount": {
907 "type": "integer",
908 "description": "Amount"
909 },
910 "currency": {
911 "description": "Currency Code",
912 "type": "string"
913 }
914 }
915 },
916 "currencies": {
917 "type": "array",
918 "items": {
919 "type": "object",
920 "properties": {
921 "currencyCode": {
922 "type": "string"
923 },
924 "evaluationDate": {
925 "type": "string",
926 "format": "date-time"
927 }
928 }
929 },
930 "example": [
931 {
932 "currencyCode": "USD",
933 "evaluationDate": "2017-07-21T17:32:28Z"
934 },
935 {
936 "currencyCode": "INR",
937 "evaluationDate": "2017-07-21T17:32:28Z"
938 }
939 ]
940 },
941 "ArrayOfInt-1": {
942 "type": "array",
943 "items": {
944 "type": "integer",
945 "format": "int64"
946 },
947 "example": [
948 1,
949 2,
950 3,
951 4
952 ]
953 },
954 "ArrayOfInt-2": {
955 "type": "array",
956 "items": {
957 "type": "integer",
958 "format": "int64",
959 "example": 1
960 }
961 },
962 "PersonObject": {
963 "type": "object",
964 "properties": {
965 "name": {
966 "type": "string"
967 },
968 "age": {
969 "type": "integer"
970 }
971 },
972 "example": {
973 "name": "name-1",
974 "age": 1
975 }
976 },
977 "ObjectWithArrayPropExample": {
978 "type": "object",
979 "properties": {
980 "numberProp": {
981 "type": "number",
982 "example": 1000
983 },
984 "stringProp": {
985 "type": "string",
986 "enum": [
987 "value0",
988 "value1"
989 ]
990 },
991 "arrayProp": {
992 "type": "array",
993 "items": {
994 "type": "number"
995 },
996 "example": [
997 0,
998 1,
999 2
1000 ]
1001 }
1002 }
1003 }
1004 }
1005 }
1006};
1007 function loadSpec() {
1008 const el = document.getElementById("thedoc");
1009 el.loadSpec(spec);
1010 }</script><script defer="defer" src="rapidoc-min.js"></script></head><body onload="loadSpec()"><rapi-doc id="thedoc" theme="light" show-header="false" show-info="false" allow-server-selection="false" allow-api-list-style-selection="false" on-nav-tag-click="show-description" render-style="focused" schema-style="table" schema-expand-level="3" info-description-headings-in-navbar="true" nav-bg-color="#fafafa" nav-hover-text-color="#000000" nav-hover-bg-color="#ECF6FD" primary-color="#012169" bg-color="#ffffff" font-size="largest" allow-authentication="false" fill-request-fields-with-example="false" show-method-in-nav-bar="as-colored-block"></rapi-doc></body></html>
\No newline at end of file