├── .gitignore ├── .travis.yml ├── README.md ├── conf └── log4j.properties ├── generated ├── document.html └── swagger-ui │ └── swagger.json ├── pom.xml ├── src └── main │ ├── java │ └── com │ │ └── github │ │ └── kongchen │ │ └── swagger │ │ └── sample │ │ └── wordnik │ │ ├── data │ │ ├── PetData.java │ │ ├── StoreData.java │ │ └── UserData.java │ │ ├── exception │ │ ├── ApiException.java │ │ ├── BadRequestException.java │ │ └── NotFoundException.java │ │ ├── model │ │ ├── ApiResponse.java │ │ ├── Category.java │ │ ├── Order.java │ │ ├── Pet.java │ │ ├── Tag.java │ │ └── User.java │ │ └── resource │ │ ├── JavaRestResourceUtil.java │ │ ├── PetResource.java │ │ ├── PetStoreResource.java │ │ └── UserResource.java │ ├── resources │ ├── logback.xml │ └── securityDefinitions.json │ └── webapp │ └── WEB-INF │ └── web.xml └── templates ├── markdown.hbs ├── operation.hbs ├── security.hbs └── strapdown.html.hbs /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | swagger-maven-example.iml 3 | target/ 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | - openjdk7 5 | - openjdk6 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Swagger Maven Plugin Example [![Build Status](https://travis-ci.org/kongchen/swagger-maven-example.png)](https://travis-ci.org/kongchen/swagger-maven-example) 2 | 3 | This project is an example of using [Swagger-maven-plugin](https://github.com/kongchen/swagger-maven-plugin). 4 | 5 | You can check the detail configuration in [pom.xml](https://github.com/kongchen/swagger-maven-example/blob/master/pom.xml#L40-L49) 6 | 7 | Clone the example in local and then launch: 8 | ``` 9 | mvn compile 10 | ``` 11 | You'll get the outputs in the */generated* folder. 12 | 13 | >If you wanna see something before clone, I've uploaded the output files, you can view swagger outputs at 14 | [here](https://github.com/kongchen/swagger-maven-example/blob/master/generated/swagger-ui), and 15 | [view the HTML output document](http://htmlpreview.github.io/?https://raw.github.com/kongchen/swagger-maven-example/master/generated/document.html) 16 | 17 | *Enjoy!* 18 | -------------------------------------------------------------------------------- /conf/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE 2 | 3 | log4j.logger.com.wordnik=ERROR 4 | log4j.logger.org.atmosphere=ERROR 5 | 6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout. 7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n 10 | 11 | # LOGFILE is set to be a File appender using a PatternLayout. 12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender 13 | log4j.appender.LOGFILE.File=logs/wordnik.log 14 | log4j.appender.LOGFILE.Append=true 15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n 17 | log4j.appender.LOGFILE.MaxFileSize=10MB 18 | log4j.appender.LOGFILE.MaxBackupIndex=10 19 | -------------------------------------------------------------------------------- /generated/document.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | API Document 4 | 5 | 6 | #Swagger Maven Plugin Sample 7 | 8 | 9 | ## HTTP | HTTPS://petstore.swagger.wordnik.com/api 10 | 11 | 12 | This is a sample for swagger-maven-plugin 13 | 14 | 15 | [**Contact the developer**](mailto:kongchen@gmail.com) 16 | 17 | 18 | **Version** v1 19 | 20 | [**Terms of Service**](http://www.github.com/kongchen/swagger-maven-plugin) 21 | 22 | [**Apache 2.0**](http://www.apache.org/licenses/LICENSE-2.0.html) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | # Security Definitions 32 | 33 | 34 | ### api_key 35 | 36 | 37 | 38 | <table> 39 | <tr> 40 | <th>type</th> 41 | <th colspan="2">apiKey</th> 42 | </tr> 43 | 44 | 45 | <tr> 46 | <th>name</th> 47 | <th colspan="2">api_key</th> 48 | </tr> 49 | 50 | 51 | <tr> 52 | <th>in</th> 53 | <th colspan="2">HEADER</th> 54 | </tr> 55 | 56 | </table> 57 | 58 | 59 | 60 | 61 | ### petstore_auth 62 | 63 | 64 | <table> 65 | <tr> 66 | <th>type</th> 67 | <th colspan="2">oauth2</th> 68 | </tr> 69 | 70 | 71 | <tr> 72 | <th>authorizationUrl</th> 73 | <th colspan="2">http://swagger.io/api/oauth/dialog</th> 74 | </tr> 75 | 76 | 77 | <tr> 78 | <th>flow</th> 79 | <th colspan="2">implicit</th> 80 | </tr> 81 | 82 | 83 | 84 | <tr> 85 | <td rowspan="3">scopes</td> 86 | 87 | <td>write:pets</td> 88 | <td>modify pets in your account</td> 89 | </tr> 90 | <tr> 91 | 92 | <td>read:pets</td> 93 | <td>read your pets</td> 94 | </tr> 95 | <tr> 96 | 97 | </tr> 98 | 99 | </table> 100 | 101 | 102 | 103 | 104 | 105 | 106 | # APIs 107 | 108 | 109 | ## /pet 110 | 111 | 112 | 113 | 114 | ### PUT 115 | 116 | <a id="updatePet">Update an existing pet</a> 117 | 118 | 119 | 120 | 121 | 122 | 123 | #### Security 124 | 125 | 126 | 127 | 128 | * petstore_auth 129 | * write:pets 130 | * read:pets 131 | 132 | 133 | 134 | 135 | #### Request 136 | 137 | 138 | **Content-Type: ** application/json, application/xml 139 | 140 | ##### Parameters 141 | 142 | <table border="1"> 143 | <tr> 144 | <th>Name</th> 145 | <th>Located in</th> 146 | <th>Required</th> 147 | <th>Description</th> 148 | <th>Default</th> 149 | <th>Schema</th> 150 | </tr> 151 | 152 | 153 | 154 | <tr> 155 | <th>body</th> 156 | <td>body</td> 157 | <td>yes</td> 158 | <td>Pet object that needs to be added to the store</td> 159 | <td> - </td> 160 | 161 | <td> 162 | 163 | <a href="#/definitions/Pet">Pet</a> 164 | </td> 165 | 166 | </tr> 167 | 168 | 169 | </table> 170 | 171 | 172 | 173 | #### Response 174 | 175 | **Content-Type: ** application/xml, application/json 176 | 177 | 178 | | Status Code | Reason | Response Model | 179 | |-------------|-------------|----------------| 180 | | 400 | Invalid ID supplied | - | 181 | | 404 | Pet not found | - | 182 | | 405 | Validation exception | - | 183 | 184 | 185 | 186 | 187 | 188 | ### POST 189 | 190 | 191 | <a id="addPet">Add a new pet to the store</a> 192 | 193 | 194 | 195 | 196 | 197 | 198 | #### Security 199 | 200 | 201 | 202 | 203 | * petstore_auth 204 | * write:pets 205 | * read:pets 206 | 207 | 208 | 209 | 210 | #### Request 211 | 212 | 213 | **Content-Type: ** application/json, application/xml 214 | 215 | ##### Parameters 216 | 217 | <table border="1"> 218 | <tr> 219 | <th>Name</th> 220 | <th>Located in</th> 221 | <th>Required</th> 222 | <th>Description</th> 223 | <th>Default</th> 224 | <th>Schema</th> 225 | </tr> 226 | 227 | 228 | 229 | <tr> 230 | <th>body</th> 231 | <td>body</td> 232 | <td>yes</td> 233 | <td>Pet object that needs to be added to the store</td> 234 | <td> - </td> 235 | 236 | <td> 237 | 238 | <a href="#/definitions/Pet">Pet</a> 239 | </td> 240 | 241 | </tr> 242 | 243 | 244 | </table> 245 | 246 | 247 | 248 | #### Response 249 | 250 | **Content-Type: ** application/xml, application/json 251 | 252 | 253 | | Status Code | Reason | Response Model | 254 | |-------------|-------------|----------------| 255 | | 405 | Invalid input | - | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | ## /pet/findByStatus 272 | 273 | 274 | ### GET 275 | 276 | <a id="findPetsByStatus">Finds Pets by status</a> 277 | 278 | Multiple status values can be provided with comma seperated strings 279 | 280 | 281 | 282 | 283 | #### Security 284 | 285 | 286 | 287 | 288 | * petstore_auth 289 | * write:pets 290 | * read:pets 291 | 292 | 293 | 294 | 295 | #### Request 296 | 297 | 298 | 299 | ##### Parameters 300 | 301 | <table border="1"> 302 | <tr> 303 | <th>Name</th> 304 | <th>Located in</th> 305 | <th>Required</th> 306 | <th>Description</th> 307 | <th>Default</th> 308 | <th>Schema</th> 309 | </tr> 310 | 311 | 312 | 313 | <tr> 314 | <th>status</th> 315 | <td>query</td> 316 | <td>yes</td> 317 | <td>Status values that need to be considered for filter</td> 318 | <td> - </td> 319 | 320 | 321 | <td>Array[string] (csv)</td> 322 | 323 | 324 | </tr> 325 | 326 | 327 | </table> 328 | 329 | 330 | 331 | #### Response 332 | 333 | **Content-Type: ** application/xml, application/json 334 | 335 | 336 | | Status Code | Reason | Response Model | 337 | |-------------|-------------|----------------| 338 | | 200 | successful operation | Array[<a href="#/definitions/Pet">Pet</a>]| 339 | | 400 | Invalid status value | - | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | ## /pet/findByTags 359 | 360 | 361 | ### GET 362 | 363 | <a id="findPetsByTags">Finds Pets by tags</a> 364 | 365 | Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. 366 | 367 | 368 | 369 | 370 | #### Security 371 | 372 | 373 | 374 | 375 | * petstore_auth 376 | * write:pets 377 | * read:pets 378 | 379 | 380 | 381 | 382 | #### Request 383 | 384 | 385 | 386 | ##### Parameters 387 | 388 | <table border="1"> 389 | <tr> 390 | <th>Name</th> 391 | <th>Located in</th> 392 | <th>Required</th> 393 | <th>Description</th> 394 | <th>Default</th> 395 | <th>Schema</th> 396 | </tr> 397 | 398 | 399 | 400 | <tr> 401 | <th>tags</th> 402 | <td>query</td> 403 | <td>yes</td> 404 | <td>Tags to filter by</td> 405 | <td> - </td> 406 | 407 | 408 | <td>Array[string] (csv)</td> 409 | 410 | 411 | </tr> 412 | 413 | 414 | </table> 415 | 416 | 417 | 418 | #### Response 419 | 420 | **Content-Type: ** application/xml, application/json 421 | 422 | 423 | | Status Code | Reason | Response Model | 424 | |-------------|-------------|----------------| 425 | | 200 | successful operation | Array[<a href="#/definitions/Pet">Pet</a>]| 426 | | 400 | Invalid tag value | - | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | ## /pet/{petId} 446 | 447 | 448 | ### GET 449 | 450 | <a id="getPetById">Find pet by ID</a> 451 | 452 | Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions 453 | 454 | 455 | 456 | 457 | #### Security 458 | 459 | 460 | 461 | 462 | * api_key 463 | 464 | 465 | 466 | 467 | * petstore_auth 468 | * write:pets 469 | * read:pets 470 | 471 | 472 | 473 | 474 | #### Request 475 | 476 | 477 | 478 | ##### Parameters 479 | 480 | <table border="1"> 481 | <tr> 482 | <th>Name</th> 483 | <th>Located in</th> 484 | <th>Required</th> 485 | <th>Description</th> 486 | <th>Default</th> 487 | <th>Schema</th> 488 | </tr> 489 | 490 | 491 | 492 | <tr> 493 | <th>petId</th> 494 | <td>path</td> 495 | <td>yes</td> 496 | <td>ID of pet that needs to be fetched</td> 497 | <td> - </td> 498 | 499 | 500 | <td>integer (int64)</td> 501 | 502 | 503 | </tr> 504 | 505 | 506 | </table> 507 | 508 | 509 | 510 | #### Response 511 | 512 | **Content-Type: ** application/xml, application/json 513 | 514 | 515 | | Status Code | Reason | Response Model | 516 | |-------------|-------------|----------------| 517 | | 200 | successful operation | <a href="#/definitions/Pet">Pet</a>| 518 | | 400 | Invalid ID supplied | - | 519 | | 404 | Pet not found | - | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | ### POST 528 | 529 | 530 | <a id="updatePetWithForm">Updates a pet in the store with form data</a> 531 | 532 | 533 | 534 | 535 | 536 | 537 | #### Security 538 | 539 | 540 | 541 | 542 | * petstore_auth 543 | * write:pets 544 | * read:pets 545 | 546 | 547 | 548 | 549 | #### Request 550 | 551 | 552 | **Content-Type: ** application/x-www-form-urlencoded 553 | 554 | ##### Parameters 555 | 556 | <table border="1"> 557 | <tr> 558 | <th>Name</th> 559 | <th>Located in</th> 560 | <th>Required</th> 561 | <th>Description</th> 562 | <th>Default</th> 563 | <th>Schema</th> 564 | </tr> 565 | 566 | 567 | 568 | <tr> 569 | <th>petId</th> 570 | <td>path</td> 571 | <td>yes</td> 572 | <td>ID of pet that needs to be updated</td> 573 | <td> - </td> 574 | 575 | 576 | <td>string </td> 577 | 578 | 579 | </tr> 580 | 581 | <tr> 582 | <th>name</th> 583 | <td>formData</td> 584 | <td>no</td> 585 | <td>Updated name of the pet</td> 586 | <td> - </td> 587 | 588 | 589 | <td>string </td> 590 | 591 | 592 | </tr> 593 | 594 | <tr> 595 | <th>status</th> 596 | <td>formData</td> 597 | <td>no</td> 598 | <td>Updated status of the pet</td> 599 | <td> - </td> 600 | 601 | 602 | <td>string </td> 603 | 604 | 605 | </tr> 606 | 607 | 608 | </table> 609 | 610 | 611 | 612 | #### Response 613 | 614 | **Content-Type: ** application/xml, application/json 615 | 616 | 617 | | Status Code | Reason | Response Model | 618 | |-------------|-------------|----------------| 619 | | 405 | Invalid input | - | 620 | 621 | 622 | 623 | 624 | 625 | 626 | ### DELETE 627 | 628 | <a id="deletePet">Deletes a pet</a> 629 | 630 | 631 | 632 | 633 | 634 | 635 | #### Security 636 | 637 | 638 | 639 | 640 | * petstore_auth 641 | * write:pets 642 | * read:pets 643 | 644 | 645 | 646 | 647 | #### Request 648 | 649 | 650 | 651 | ##### Parameters 652 | 653 | <table border="1"> 654 | <tr> 655 | <th>Name</th> 656 | <th>Located in</th> 657 | <th>Required</th> 658 | <th>Description</th> 659 | <th>Default</th> 660 | <th>Schema</th> 661 | </tr> 662 | 663 | 664 | 665 | <tr> 666 | <th>api_key</th> 667 | <td>header</td> 668 | <td>no</td> 669 | <td></td> 670 | <td> - </td> 671 | 672 | 673 | <td>string </td> 674 | 675 | 676 | </tr> 677 | 678 | <tr> 679 | <th>petId</th> 680 | <td>path</td> 681 | <td>yes</td> 682 | <td>Pet id to delete</td> 683 | <td> - </td> 684 | 685 | 686 | <td>integer (int64)</td> 687 | 688 | 689 | </tr> 690 | 691 | 692 | </table> 693 | 694 | 695 | 696 | #### Response 697 | 698 | **Content-Type: ** application/xml, application/json 699 | 700 | 701 | | Status Code | Reason | Response Model | 702 | |-------------|-------------|----------------| 703 | | 400 | Invalid pet value | - | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | ## /store/order 717 | 718 | 719 | 720 | 721 | 722 | 723 | ### POST 724 | 725 | 726 | <a id="placeOrder">Place an order for a pet</a> 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | #### Request 737 | 738 | 739 | 740 | ##### Parameters 741 | 742 | <table border="1"> 743 | <tr> 744 | <th>Name</th> 745 | <th>Located in</th> 746 | <th>Required</th> 747 | <th>Description</th> 748 | <th>Default</th> 749 | <th>Schema</th> 750 | </tr> 751 | 752 | 753 | 754 | <tr> 755 | <th>body</th> 756 | <td>body</td> 757 | <td>yes</td> 758 | <td>order placed for purchasing the pet</td> 759 | <td> - </td> 760 | 761 | <td> 762 | 763 | <a href="#/definitions/Order">Order</a> 764 | </td> 765 | 766 | </tr> 767 | 768 | 769 | </table> 770 | 771 | 772 | 773 | #### Response 774 | 775 | **Content-Type: ** application/xml, application/json 776 | 777 | 778 | | Status Code | Reason | Response Model | 779 | |-------------|-------------|----------------| 780 | | 200 | successful operation | <a href="#/definitions/Order">Order</a>| 781 | | 400 | Invalid Order | - | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | ## /store/order/{orderId} 798 | 799 | 800 | ### GET 801 | 802 | <a id="getOrderById">Find purchase order by ID</a> 803 | 804 | For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | #### Request 813 | 814 | 815 | 816 | ##### Parameters 817 | 818 | <table border="1"> 819 | <tr> 820 | <th>Name</th> 821 | <th>Located in</th> 822 | <th>Required</th> 823 | <th>Description</th> 824 | <th>Default</th> 825 | <th>Schema</th> 826 | </tr> 827 | 828 | 829 | 830 | <tr> 831 | <th>orderId</th> 832 | <td>path</td> 833 | <td>yes</td> 834 | <td>ID of pet that needs to be fetched</td> 835 | <td> - </td> 836 | 837 | 838 | <td>string </td> 839 | 840 | 841 | </tr> 842 | 843 | 844 | </table> 845 | 846 | 847 | 848 | #### Response 849 | 850 | **Content-Type: ** application/xml, application/json 851 | 852 | 853 | | Status Code | Reason | Response Model | 854 | |-------------|-------------|----------------| 855 | | 200 | successful operation | <a href="#/definitions/Order">Order</a>| 856 | | 400 | Invalid ID supplied | - | 857 | | 404 | Order not found | - | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | ### DELETE 868 | 869 | <a id="deleteOrder">Delete purchase order by ID</a> 870 | 871 | For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | #### Request 880 | 881 | 882 | 883 | ##### Parameters 884 | 885 | <table border="1"> 886 | <tr> 887 | <th>Name</th> 888 | <th>Located in</th> 889 | <th>Required</th> 890 | <th>Description</th> 891 | <th>Default</th> 892 | <th>Schema</th> 893 | </tr> 894 | 895 | 896 | 897 | <tr> 898 | <th>orderId</th> 899 | <td>path</td> 900 | <td>yes</td> 901 | <td>ID of the order that needs to be deleted</td> 902 | <td> - </td> 903 | 904 | 905 | <td>string </td> 906 | 907 | 908 | </tr> 909 | 910 | 911 | </table> 912 | 913 | 914 | 915 | #### Response 916 | 917 | **Content-Type: ** application/xml, application/json 918 | 919 | 920 | | Status Code | Reason | Response Model | 921 | |-------------|-------------|----------------| 922 | | 400 | Invalid ID supplied | - | 923 | | 404 | Order not found | - | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | ## /user 937 | 938 | 939 | 940 | 941 | 942 | 943 | ### POST 944 | 945 | 946 | <a id="createUser">Create user</a> 947 | 948 | This can only be done by the logged in user. 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | #### Request 957 | 958 | 959 | 960 | ##### Parameters 961 | 962 | <table border="1"> 963 | <tr> 964 | <th>Name</th> 965 | <th>Located in</th> 966 | <th>Required</th> 967 | <th>Description</th> 968 | <th>Default</th> 969 | <th>Schema</th> 970 | </tr> 971 | 972 | 973 | 974 | <tr> 975 | <th>body</th> 976 | <td>body</td> 977 | <td>yes</td> 978 | <td>Created user object</td> 979 | <td> - </td> 980 | 981 | <td> 982 | 983 | <a href="#/definitions/User">User</a> 984 | </td> 985 | 986 | </tr> 987 | 988 | 989 | </table> 990 | 991 | 992 | 993 | #### Response 994 | 995 | **Content-Type: ** application/xml, application/json 996 | 997 | 998 | | Status Code | Reason | Response Model | 999 | |-------------|-------------|----------------| 1000 | | default | successful operation | - | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | ## /user/createWithArray 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | ### POST 1024 | 1025 | 1026 | <a id="createUsersWithArrayInput">Creates list of users with given input array</a> 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | #### Request 1037 | 1038 | 1039 | 1040 | ##### Parameters 1041 | 1042 | <table border="1"> 1043 | <tr> 1044 | <th>Name</th> 1045 | <th>Located in</th> 1046 | <th>Required</th> 1047 | <th>Description</th> 1048 | <th>Default</th> 1049 | <th>Schema</th> 1050 | </tr> 1051 | 1052 | 1053 | 1054 | <tr> 1055 | <th>body</th> 1056 | <td>body</td> 1057 | <td>yes</td> 1058 | <td>List of user object</td> 1059 | <td> - </td> 1060 | 1061 | <td> 1062 | Array[<a href="#/definitions/User">User</a>] 1063 | 1064 | </td> 1065 | 1066 | </tr> 1067 | 1068 | 1069 | </table> 1070 | 1071 | 1072 | 1073 | #### Response 1074 | 1075 | **Content-Type: ** application/xml, application/json 1076 | 1077 | 1078 | | Status Code | Reason | Response Model | 1079 | |-------------|-------------|----------------| 1080 | | default | successful operation | - | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | ## /user/createWithList 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | ### POST 1104 | 1105 | 1106 | <a id="createUsersWithListInput">Creates list of users with given input array</a> 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | #### Request 1117 | 1118 | 1119 | 1120 | ##### Parameters 1121 | 1122 | <table border="1"> 1123 | <tr> 1124 | <th>Name</th> 1125 | <th>Located in</th> 1126 | <th>Required</th> 1127 | <th>Description</th> 1128 | <th>Default</th> 1129 | <th>Schema</th> 1130 | </tr> 1131 | 1132 | 1133 | 1134 | <tr> 1135 | <th>body</th> 1136 | <td>body</td> 1137 | <td>yes</td> 1138 | <td>List of user object</td> 1139 | <td> - </td> 1140 | 1141 | <td> 1142 | Array[<a href="#/definitions/User">User</a>] 1143 | 1144 | </td> 1145 | 1146 | </tr> 1147 | 1148 | 1149 | </table> 1150 | 1151 | 1152 | 1153 | #### Response 1154 | 1155 | **Content-Type: ** application/xml, application/json 1156 | 1157 | 1158 | | Status Code | Reason | Response Model | 1159 | |-------------|-------------|----------------| 1160 | | default | successful operation | - | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | ## /user/login 1177 | 1178 | 1179 | ### GET 1180 | 1181 | <a id="loginUser">Logs user into the system</a> 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | #### Request 1192 | 1193 | 1194 | 1195 | ##### Parameters 1196 | 1197 | <table border="1"> 1198 | <tr> 1199 | <th>Name</th> 1200 | <th>Located in</th> 1201 | <th>Required</th> 1202 | <th>Description</th> 1203 | <th>Default</th> 1204 | <th>Schema</th> 1205 | </tr> 1206 | 1207 | 1208 | 1209 | <tr> 1210 | <th>username</th> 1211 | <td>query</td> 1212 | <td>yes</td> 1213 | <td>The user name for login</td> 1214 | <td> - </td> 1215 | 1216 | 1217 | <td>string </td> 1218 | 1219 | 1220 | </tr> 1221 | 1222 | <tr> 1223 | <th>password</th> 1224 | <td>query</td> 1225 | <td>yes</td> 1226 | <td>The password for login in clear text</td> 1227 | <td> - </td> 1228 | 1229 | 1230 | <td>string </td> 1231 | 1232 | 1233 | </tr> 1234 | 1235 | 1236 | </table> 1237 | 1238 | 1239 | 1240 | #### Response 1241 | 1242 | **Content-Type: ** application/xml, application/json 1243 | 1244 | 1245 | | Status Code | Reason | Response Model | 1246 | |-------------|-------------|----------------| 1247 | | 200 | successful operation | | 1248 | | 400 | Invalid username/password supplied | - | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | ## /user/logout 1268 | 1269 | 1270 | ### GET 1271 | 1272 | <a id="logoutUser">Logs out current logged in user session</a> 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | #### Request 1283 | 1284 | 1285 | 1286 | ##### Parameters 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | #### Response 1294 | 1295 | **Content-Type: ** application/xml, application/json 1296 | 1297 | 1298 | | Status Code | Reason | Response Model | 1299 | |-------------|-------------|----------------| 1300 | | default | successful operation | - | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | ## /user/{username} 1320 | 1321 | 1322 | ### GET 1323 | 1324 | <a id="getUserByName">Get user by user name</a> 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | #### Request 1335 | 1336 | 1337 | 1338 | ##### Parameters 1339 | 1340 | <table border="1"> 1341 | <tr> 1342 | <th>Name</th> 1343 | <th>Located in</th> 1344 | <th>Required</th> 1345 | <th>Description</th> 1346 | <th>Default</th> 1347 | <th>Schema</th> 1348 | </tr> 1349 | 1350 | 1351 | 1352 | <tr> 1353 | <th>username</th> 1354 | <td>path</td> 1355 | <td>yes</td> 1356 | <td>The name that needs to be fetched. Use user1 for testing. </td> 1357 | <td> - </td> 1358 | 1359 | 1360 | <td>string </td> 1361 | 1362 | 1363 | </tr> 1364 | 1365 | 1366 | </table> 1367 | 1368 | 1369 | 1370 | #### Response 1371 | 1372 | **Content-Type: ** application/xml, application/json 1373 | 1374 | 1375 | | Status Code | Reason | Response Model | 1376 | |-------------|-------------|----------------| 1377 | | 200 | successful operation | <a href="#/definitions/User">User</a>| 1378 | | 400 | Invalid username supplied | - | 1379 | | 404 | User not found | - | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | ### PUT 1386 | 1387 | <a id="updateUser">Updated user</a> 1388 | 1389 | This can only be done by the logged in user. 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | #### Request 1398 | 1399 | 1400 | 1401 | ##### Parameters 1402 | 1403 | <table border="1"> 1404 | <tr> 1405 | <th>Name</th> 1406 | <th>Located in</th> 1407 | <th>Required</th> 1408 | <th>Description</th> 1409 | <th>Default</th> 1410 | <th>Schema</th> 1411 | </tr> 1412 | 1413 | 1414 | 1415 | <tr> 1416 | <th>username</th> 1417 | <td>path</td> 1418 | <td>yes</td> 1419 | <td>name that need to be deleted</td> 1420 | <td> - </td> 1421 | 1422 | 1423 | <td>string </td> 1424 | 1425 | 1426 | </tr> 1427 | 1428 | <tr> 1429 | <th>body</th> 1430 | <td>body</td> 1431 | <td>yes</td> 1432 | <td>Updated user object</td> 1433 | <td> - </td> 1434 | 1435 | <td> 1436 | 1437 | <a href="#/definitions/User">User</a> 1438 | </td> 1439 | 1440 | </tr> 1441 | 1442 | 1443 | </table> 1444 | 1445 | 1446 | 1447 | #### Response 1448 | 1449 | **Content-Type: ** application/xml, application/json 1450 | 1451 | 1452 | | Status Code | Reason | Response Model | 1453 | |-------------|-------------|----------------| 1454 | | 400 | Invalid user supplied | - | 1455 | | 404 | User not found | - | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | ### DELETE 1464 | 1465 | <a id="deleteUser">Delete user</a> 1466 | 1467 | This can only be done by the logged in user. 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | #### Request 1476 | 1477 | 1478 | 1479 | ##### Parameters 1480 | 1481 | <table border="1"> 1482 | <tr> 1483 | <th>Name</th> 1484 | <th>Located in</th> 1485 | <th>Required</th> 1486 | <th>Description</th> 1487 | <th>Default</th> 1488 | <th>Schema</th> 1489 | </tr> 1490 | 1491 | 1492 | 1493 | <tr> 1494 | <th>username</th> 1495 | <td>path</td> 1496 | <td>yes</td> 1497 | <td>The name that needs to be deleted</td> 1498 | <td> - </td> 1499 | 1500 | 1501 | <td>string </td> 1502 | 1503 | 1504 | </tr> 1505 | 1506 | 1507 | </table> 1508 | 1509 | 1510 | 1511 | #### Response 1512 | 1513 | **Content-Type: ** application/xml, application/json 1514 | 1515 | 1516 | | Status Code | Reason | Response Model | 1517 | |-------------|-------------|----------------| 1518 | | 400 | Invalid username supplied | - | 1519 | | 404 | User not found | - | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | # Definitions 1534 | 1535 | ## <a name="/definitions/Category">Category</a> 1536 | 1537 | <table border="1"> 1538 | <tr> 1539 | <th>name</th> 1540 | <th>type</th> 1541 | <th>required</th> 1542 | <th>description</th> 1543 | <th>example</th> 1544 | </tr> 1545 | 1546 | <tr> 1547 | <td>id</td> 1548 | <td> 1549 | 1550 | 1551 | integer (int64) 1552 | 1553 | </td> 1554 | <td>optional</td> 1555 | <td>-</td> 1556 | <td></td> 1557 | </tr> 1558 | 1559 | <tr> 1560 | <td>name</td> 1561 | <td> 1562 | 1563 | 1564 | string 1565 | 1566 | </td> 1567 | <td>optional</td> 1568 | <td>-</td> 1569 | <td></td> 1570 | </tr> 1571 | 1572 | </table> 1573 | 1574 | ## <a name="/definitions/Order">Order</a> 1575 | 1576 | <table border="1"> 1577 | <tr> 1578 | <th>name</th> 1579 | <th>type</th> 1580 | <th>required</th> 1581 | <th>description</th> 1582 | <th>example</th> 1583 | </tr> 1584 | 1585 | <tr> 1586 | <td>id</td> 1587 | <td> 1588 | 1589 | 1590 | integer (int64) 1591 | 1592 | </td> 1593 | <td>optional</td> 1594 | <td>-</td> 1595 | <td></td> 1596 | </tr> 1597 | 1598 | <tr> 1599 | <td>petId</td> 1600 | <td> 1601 | 1602 | 1603 | integer (int64) 1604 | 1605 | </td> 1606 | <td>optional</td> 1607 | <td>-</td> 1608 | <td></td> 1609 | </tr> 1610 | 1611 | <tr> 1612 | <td>quantity</td> 1613 | <td> 1614 | 1615 | 1616 | integer (int32) 1617 | 1618 | </td> 1619 | <td>optional</td> 1620 | <td>-</td> 1621 | <td></td> 1622 | </tr> 1623 | 1624 | <tr> 1625 | <td>shipDate</td> 1626 | <td> 1627 | 1628 | 1629 | string (date-time) 1630 | 1631 | </td> 1632 | <td>optional</td> 1633 | <td>-</td> 1634 | <td></td> 1635 | </tr> 1636 | 1637 | <tr> 1638 | <td>status</td> 1639 | <td> 1640 | 1641 | 1642 | string 1643 | 1644 | </td> 1645 | <td>optional</td> 1646 | <td>Order Status</td> 1647 | <td></td> 1648 | </tr> 1649 | 1650 | <tr> 1651 | <td>complete</td> 1652 | <td> 1653 | 1654 | 1655 | boolean 1656 | 1657 | </td> 1658 | <td>optional</td> 1659 | <td>-</td> 1660 | <td></td> 1661 | </tr> 1662 | 1663 | </table> 1664 | 1665 | ## <a name="/definitions/Pet">Pet</a> 1666 | 1667 | <table border="1"> 1668 | <tr> 1669 | <th>name</th> 1670 | <th>type</th> 1671 | <th>required</th> 1672 | <th>description</th> 1673 | <th>example</th> 1674 | </tr> 1675 | 1676 | <tr> 1677 | <td>id</td> 1678 | <td> 1679 | 1680 | 1681 | integer (int64) 1682 | 1683 | </td> 1684 | <td>optional</td> 1685 | <td>-</td> 1686 | <td></td> 1687 | </tr> 1688 | 1689 | <tr> 1690 | <td>category</td> 1691 | <td> 1692 | 1693 | <a href="#/definitions/Category">Category</a> 1694 | 1695 | 1696 | </td> 1697 | <td>optional</td> 1698 | <td>-</td> 1699 | <td></td> 1700 | </tr> 1701 | 1702 | <tr> 1703 | <td>name</td> 1704 | <td> 1705 | 1706 | 1707 | string 1708 | 1709 | </td> 1710 | <td>required</td> 1711 | <td>-</td> 1712 | <td>doggie</td> 1713 | </tr> 1714 | 1715 | <tr> 1716 | <td>photoUrls</td> 1717 | <td> 1718 | 1719 | 1720 | array[string] 1721 | 1722 | </td> 1723 | <td>required</td> 1724 | <td>-</td> 1725 | <td></td> 1726 | </tr> 1727 | 1728 | <tr> 1729 | <td>tags</td> 1730 | <td> 1731 | 1732 | 1733 | array[<a href="#/definitions/Tag">Tag</a>] 1734 | 1735 | 1736 | 1737 | </td> 1738 | <td>optional</td> 1739 | <td>-</td> 1740 | <td></td> 1741 | </tr> 1742 | 1743 | <tr> 1744 | <td>status</td> 1745 | <td> 1746 | 1747 | 1748 | string 1749 | 1750 | </td> 1751 | <td>optional</td> 1752 | <td>pet status in the store</td> 1753 | <td></td> 1754 | </tr> 1755 | 1756 | </table> 1757 | 1758 | ## <a name="/definitions/Tag">Tag</a> 1759 | 1760 | <table border="1"> 1761 | <tr> 1762 | <th>name</th> 1763 | <th>type</th> 1764 | <th>required</th> 1765 | <th>description</th> 1766 | <th>example</th> 1767 | </tr> 1768 | 1769 | <tr> 1770 | <td>id</td> 1771 | <td> 1772 | 1773 | 1774 | integer (int64) 1775 | 1776 | </td> 1777 | <td>optional</td> 1778 | <td>-</td> 1779 | <td></td> 1780 | </tr> 1781 | 1782 | <tr> 1783 | <td>name</td> 1784 | <td> 1785 | 1786 | 1787 | string 1788 | 1789 | </td> 1790 | <td>optional</td> 1791 | <td>-</td> 1792 | <td></td> 1793 | </tr> 1794 | 1795 | </table> 1796 | 1797 | ## <a name="/definitions/User">User</a> 1798 | 1799 | <table border="1"> 1800 | <tr> 1801 | <th>name</th> 1802 | <th>type</th> 1803 | <th>required</th> 1804 | <th>description</th> 1805 | <th>example</th> 1806 | </tr> 1807 | 1808 | <tr> 1809 | <td>id</td> 1810 | <td> 1811 | 1812 | 1813 | integer (int64) 1814 | 1815 | </td> 1816 | <td>optional</td> 1817 | <td>-</td> 1818 | <td></td> 1819 | </tr> 1820 | 1821 | <tr> 1822 | <td>username</td> 1823 | <td> 1824 | 1825 | 1826 | string 1827 | 1828 | </td> 1829 | <td>optional</td> 1830 | <td>-</td> 1831 | <td></td> 1832 | </tr> 1833 | 1834 | <tr> 1835 | <td>firstName</td> 1836 | <td> 1837 | 1838 | 1839 | string 1840 | 1841 | </td> 1842 | <td>optional</td> 1843 | <td>-</td> 1844 | <td></td> 1845 | </tr> 1846 | 1847 | <tr> 1848 | <td>lastName</td> 1849 | <td> 1850 | 1851 | 1852 | string 1853 | 1854 | </td> 1855 | <td>optional</td> 1856 | <td>-</td> 1857 | <td></td> 1858 | </tr> 1859 | 1860 | <tr> 1861 | <td>email</td> 1862 | <td> 1863 | 1864 | 1865 | string 1866 | 1867 | </td> 1868 | <td>optional</td> 1869 | <td>-</td> 1870 | <td></td> 1871 | </tr> 1872 | 1873 | <tr> 1874 | <td>password</td> 1875 | <td> 1876 | 1877 | 1878 | string 1879 | 1880 | </td> 1881 | <td>optional</td> 1882 | <td>-</td> 1883 | <td></td> 1884 | </tr> 1885 | 1886 | <tr> 1887 | <td>phone</td> 1888 | <td> 1889 | 1890 | 1891 | string 1892 | 1893 | </td> 1894 | <td>optional</td> 1895 | <td>-</td> 1896 | <td></td> 1897 | </tr> 1898 | 1899 | <tr> 1900 | <td>userStatus</td> 1901 | <td> 1902 | 1903 | 1904 | integer (int32) 1905 | 1906 | </td> 1907 | <td>optional</td> 1908 | <td>User Status</td> 1909 | <td></td> 1910 | </tr> 1911 | 1912 | </table> 1913 | 1914 | 1915 | 1916 | 1917 | 1918 | 1919 | -------------------------------------------------------------------------------- /generated/swagger-ui/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger" : "2.0", 3 | "info" : { 4 | "description" : "This is a sample for swagger-maven-plugin", 5 | "version" : "v1", 6 | "title" : "Swagger Maven Plugin Sample", 7 | "termsOfService" : "http://www.github.com/kongchen/swagger-maven-plugin", 8 | "contact" : { 9 | "name" : "Kong Chen", 10 | "url" : "http://kongch.com", 11 | "email" : "kongchen@gmail.com" 12 | }, 13 | "license" : { 14 | "name" : "Apache 2.0", 15 | "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" 16 | } 17 | }, 18 | "host" : "petstore.swagger.wordnik.com", 19 | "basePath" : "/api", 20 | "tags" : [ { 21 | "name" : "store" 22 | }, { 23 | "name" : "user" 24 | }, { 25 | "name" : "pet" 26 | } ], 27 | "schemes" : [ "http", "https" ], 28 | "paths" : { 29 | "/pet" : { 30 | "post" : { 31 | "tags" : [ "pet" ], 32 | "summary" : "Add a new pet to the store", 33 | "description" : "", 34 | "operationId" : "addPet", 35 | "consumes" : [ "application/json", "application/xml" ], 36 | "produces" : [ "application/xml", "application/json" ], 37 | "parameters" : [ { 38 | "in" : "body", 39 | "name" : "body", 40 | "description" : "Pet object that needs to be added to the store", 41 | "required" : true, 42 | "schema" : { 43 | "$ref" : "#/definitions/Pet" 44 | } 45 | } ], 46 | "responses" : { 47 | "405" : { 48 | "description" : "Invalid input" 49 | } 50 | }, 51 | "security" : [ { 52 | "petstore_auth" : [ "write:pets", "read:pets" ] 53 | } ] 54 | }, 55 | "put" : { 56 | "tags" : [ "pet" ], 57 | "summary" : "Update an existing pet", 58 | "description" : "", 59 | "operationId" : "updatePet", 60 | "consumes" : [ "application/json", "application/xml" ], 61 | "produces" : [ "application/xml", "application/json" ], 62 | "parameters" : [ { 63 | "in" : "body", 64 | "name" : "body", 65 | "description" : "Pet object that needs to be added to the store", 66 | "required" : true, 67 | "schema" : { 68 | "$ref" : "#/definitions/Pet" 69 | } 70 | } ], 71 | "responses" : { 72 | "400" : { 73 | "description" : "Invalid ID supplied" 74 | }, 75 | "404" : { 76 | "description" : "Pet not found" 77 | }, 78 | "405" : { 79 | "description" : "Validation exception" 80 | } 81 | }, 82 | "security" : [ { 83 | "petstore_auth" : [ "write:pets", "read:pets" ] 84 | } ] 85 | } 86 | }, 87 | "/pet/findByStatus" : { 88 | "get" : { 89 | "tags" : [ "pet" ], 90 | "summary" : "Finds Pets by status", 91 | "description" : "Multiple status values can be provided with comma seperated strings", 92 | "operationId" : "findPetsByStatus", 93 | "produces" : [ "application/xml", "application/json" ], 94 | "parameters" : [ { 95 | "name" : "status", 96 | "in" : "query", 97 | "description" : "Status values that need to be considered for filter", 98 | "required" : true, 99 | "type" : "array", 100 | "items" : { 101 | "type" : "string", 102 | "default" : "available", 103 | "enum" : [ "available", "pending", "sold" ] 104 | }, 105 | "collectionFormat" : "csv" 106 | } ], 107 | "responses" : { 108 | "200" : { 109 | "description" : "successful operation", 110 | "schema" : { 111 | "type" : "array", 112 | "items" : { 113 | "$ref" : "#/definitions/Pet" 114 | } 115 | } 116 | }, 117 | "400" : { 118 | "description" : "Invalid status value" 119 | } 120 | }, 121 | "security" : [ { 122 | "petstore_auth" : [ "write:pets", "read:pets" ] 123 | } ] 124 | } 125 | }, 126 | "/pet/findByTags" : { 127 | "get" : { 128 | "tags" : [ "pet" ], 129 | "summary" : "Finds Pets by tags", 130 | "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", 131 | "operationId" : "findPetsByTags", 132 | "produces" : [ "application/xml", "application/json" ], 133 | "parameters" : [ { 134 | "name" : "tags", 135 | "in" : "query", 136 | "description" : "Tags to filter by", 137 | "required" : true, 138 | "type" : "array", 139 | "items" : { 140 | "type" : "string" 141 | }, 142 | "collectionFormat" : "csv" 143 | } ], 144 | "responses" : { 145 | "200" : { 146 | "description" : "successful operation", 147 | "schema" : { 148 | "type" : "array", 149 | "items" : { 150 | "$ref" : "#/definitions/Pet" 151 | } 152 | } 153 | }, 154 | "400" : { 155 | "description" : "Invalid tag value" 156 | } 157 | }, 158 | "security" : [ { 159 | "petstore_auth" : [ "write:pets", "read:pets" ] 160 | } ] 161 | } 162 | }, 163 | "/pet/{petId}" : { 164 | "get" : { 165 | "tags" : [ "pet" ], 166 | "summary" : "Find pet by ID", 167 | "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", 168 | "operationId" : "getPetById", 169 | "produces" : [ "application/xml", "application/json" ], 170 | "parameters" : [ { 171 | "name" : "petId", 172 | "in" : "path", 173 | "description" : "ID of pet that needs to be fetched", 174 | "required" : true, 175 | "type" : "integer", 176 | "maximum" : 5.0, 177 | "minimum" : 1.0, 178 | "format" : "int64" 179 | } ], 180 | "responses" : { 181 | "200" : { 182 | "description" : "successful operation", 183 | "schema" : { 184 | "$ref" : "#/definitions/Pet" 185 | } 186 | }, 187 | "400" : { 188 | "description" : "Invalid ID supplied" 189 | }, 190 | "404" : { 191 | "description" : "Pet not found" 192 | } 193 | }, 194 | "security" : [ { 195 | "api_key" : [ ] 196 | }, { 197 | "petstore_auth" : [ "write:pets", "read:pets" ] 198 | } ] 199 | }, 200 | "post" : { 201 | "tags" : [ "pet" ], 202 | "summary" : "Updates a pet in the store with form data", 203 | "description" : "", 204 | "operationId" : "updatePetWithForm", 205 | "consumes" : [ "application/x-www-form-urlencoded" ], 206 | "produces" : [ "application/xml", "application/json" ], 207 | "parameters" : [ { 208 | "name" : "petId", 209 | "in" : "path", 210 | "description" : "ID of pet that needs to be updated", 211 | "required" : true, 212 | "type" : "string" 213 | }, { 214 | "name" : "name", 215 | "in" : "formData", 216 | "description" : "Updated name of the pet", 217 | "required" : false, 218 | "type" : "string" 219 | }, { 220 | "name" : "status", 221 | "in" : "formData", 222 | "description" : "Updated status of the pet", 223 | "required" : false, 224 | "type" : "string" 225 | } ], 226 | "responses" : { 227 | "405" : { 228 | "description" : "Invalid input" 229 | } 230 | }, 231 | "security" : [ { 232 | "petstore_auth" : [ "write:pets", "read:pets" ] 233 | } ] 234 | }, 235 | "delete" : { 236 | "tags" : [ "pet" ], 237 | "summary" : "Deletes a pet", 238 | "description" : "", 239 | "operationId" : "deletePet", 240 | "produces" : [ "application/xml", "application/json" ], 241 | "parameters" : [ { 242 | "name" : "api_key", 243 | "in" : "header", 244 | "required" : false, 245 | "type" : "string", 246 | "default" : "" 247 | }, { 248 | "name" : "petId", 249 | "in" : "path", 250 | "description" : "Pet id to delete", 251 | "required" : true, 252 | "type" : "integer", 253 | "format" : "int64" 254 | } ], 255 | "responses" : { 256 | "400" : { 257 | "description" : "Invalid pet value" 258 | } 259 | }, 260 | "security" : [ { 261 | "petstore_auth" : [ "write:pets", "read:pets" ] 262 | } ] 263 | } 264 | }, 265 | "/store/order" : { 266 | "post" : { 267 | "tags" : [ "store" ], 268 | "summary" : "Place an order for a pet", 269 | "description" : "", 270 | "operationId" : "placeOrder", 271 | "produces" : [ "application/xml", "application/json" ], 272 | "parameters" : [ { 273 | "in" : "body", 274 | "name" : "body", 275 | "description" : "order placed for purchasing the pet", 276 | "required" : true, 277 | "schema" : { 278 | "$ref" : "#/definitions/Order" 279 | } 280 | } ], 281 | "responses" : { 282 | "200" : { 283 | "description" : "successful operation", 284 | "schema" : { 285 | "$ref" : "#/definitions/Order" 286 | } 287 | }, 288 | "400" : { 289 | "description" : "Invalid Order" 290 | } 291 | } 292 | } 293 | }, 294 | "/store/order/{orderId}" : { 295 | "get" : { 296 | "tags" : [ "store" ], 297 | "summary" : "Find purchase order by ID", 298 | "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", 299 | "operationId" : "getOrderById", 300 | "produces" : [ "application/xml", "application/json" ], 301 | "parameters" : [ { 302 | "name" : "orderId", 303 | "in" : "path", 304 | "description" : "ID of pet that needs to be fetched", 305 | "required" : true, 306 | "type" : "string", 307 | "maximum" : 5.0, 308 | "minimum" : 1.0 309 | } ], 310 | "responses" : { 311 | "200" : { 312 | "description" : "successful operation", 313 | "schema" : { 314 | "$ref" : "#/definitions/Order" 315 | } 316 | }, 317 | "400" : { 318 | "description" : "Invalid ID supplied" 319 | }, 320 | "404" : { 321 | "description" : "Order not found" 322 | } 323 | } 324 | }, 325 | "delete" : { 326 | "tags" : [ "store" ], 327 | "summary" : "Delete purchase order by ID", 328 | "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", 329 | "operationId" : "deleteOrder", 330 | "produces" : [ "application/xml", "application/json" ], 331 | "parameters" : [ { 332 | "name" : "orderId", 333 | "in" : "path", 334 | "description" : "ID of the order that needs to be deleted", 335 | "required" : true, 336 | "type" : "string", 337 | "minimum" : 1.0 338 | } ], 339 | "responses" : { 340 | "400" : { 341 | "description" : "Invalid ID supplied" 342 | }, 343 | "404" : { 344 | "description" : "Order not found" 345 | } 346 | } 347 | } 348 | }, 349 | "/user" : { 350 | "post" : { 351 | "tags" : [ "user" ], 352 | "summary" : "Create user", 353 | "description" : "This can only be done by the logged in user.", 354 | "operationId" : "createUser", 355 | "produces" : [ "application/xml", "application/json" ], 356 | "parameters" : [ { 357 | "in" : "body", 358 | "name" : "body", 359 | "description" : "Created user object", 360 | "required" : true, 361 | "schema" : { 362 | "$ref" : "#/definitions/User" 363 | } 364 | } ], 365 | "responses" : { 366 | "default" : { 367 | "description" : "successful operation" 368 | } 369 | } 370 | } 371 | }, 372 | "/user/createWithArray" : { 373 | "post" : { 374 | "tags" : [ "user" ], 375 | "summary" : "Creates list of users with given input array", 376 | "description" : "", 377 | "operationId" : "createUsersWithArrayInput", 378 | "produces" : [ "application/xml", "application/json" ], 379 | "parameters" : [ { 380 | "in" : "body", 381 | "name" : "body", 382 | "description" : "List of user object", 383 | "required" : true, 384 | "schema" : { 385 | "type" : "array", 386 | "items" : { 387 | "$ref" : "#/definitions/User" 388 | } 389 | } 390 | } ], 391 | "responses" : { 392 | "default" : { 393 | "description" : "successful operation" 394 | } 395 | } 396 | } 397 | }, 398 | "/user/createWithList" : { 399 | "post" : { 400 | "tags" : [ "user" ], 401 | "summary" : "Creates list of users with given input array", 402 | "description" : "", 403 | "operationId" : "createUsersWithListInput", 404 | "produces" : [ "application/xml", "application/json" ], 405 | "parameters" : [ { 406 | "in" : "body", 407 | "name" : "body", 408 | "description" : "List of user object", 409 | "required" : true, 410 | "schema" : { 411 | "type" : "array", 412 | "items" : { 413 | "$ref" : "#/definitions/User" 414 | } 415 | } 416 | } ], 417 | "responses" : { 418 | "default" : { 419 | "description" : "successful operation" 420 | } 421 | } 422 | } 423 | }, 424 | "/user/login" : { 425 | "get" : { 426 | "tags" : [ "user" ], 427 | "summary" : "Logs user into the system", 428 | "description" : "", 429 | "operationId" : "loginUser", 430 | "produces" : [ "application/xml", "application/json" ], 431 | "parameters" : [ { 432 | "name" : "username", 433 | "in" : "query", 434 | "description" : "The user name for login", 435 | "required" : true, 436 | "type" : "string" 437 | }, { 438 | "name" : "password", 439 | "in" : "query", 440 | "description" : "The password for login in clear text", 441 | "required" : true, 442 | "type" : "string" 443 | } ], 444 | "responses" : { 445 | "200" : { 446 | "description" : "successful operation", 447 | "schema" : { 448 | "type" : "string" 449 | } 450 | }, 451 | "400" : { 452 | "description" : "Invalid username/password supplied" 453 | } 454 | } 455 | } 456 | }, 457 | "/user/logout" : { 458 | "get" : { 459 | "tags" : [ "user" ], 460 | "summary" : "Logs out current logged in user session", 461 | "description" : "", 462 | "operationId" : "logoutUser", 463 | "produces" : [ "application/xml", "application/json" ], 464 | "responses" : { 465 | "default" : { 466 | "description" : "successful operation" 467 | } 468 | } 469 | } 470 | }, 471 | "/user/{username}" : { 472 | "get" : { 473 | "tags" : [ "user" ], 474 | "summary" : "Get user by user name", 475 | "description" : "", 476 | "operationId" : "getUserByName", 477 | "produces" : [ "application/xml", "application/json" ], 478 | "parameters" : [ { 479 | "name" : "username", 480 | "in" : "path", 481 | "description" : "The name that needs to be fetched. Use user1 for testing. ", 482 | "required" : true, 483 | "type" : "string" 484 | } ], 485 | "responses" : { 486 | "200" : { 487 | "description" : "successful operation", 488 | "schema" : { 489 | "$ref" : "#/definitions/User" 490 | } 491 | }, 492 | "400" : { 493 | "description" : "Invalid username supplied" 494 | }, 495 | "404" : { 496 | "description" : "User not found" 497 | } 498 | } 499 | }, 500 | "put" : { 501 | "tags" : [ "user" ], 502 | "summary" : "Updated user", 503 | "description" : "This can only be done by the logged in user.", 504 | "operationId" : "updateUser", 505 | "produces" : [ "application/xml", "application/json" ], 506 | "parameters" : [ { 507 | "name" : "username", 508 | "in" : "path", 509 | "description" : "name that need to be deleted", 510 | "required" : true, 511 | "type" : "string" 512 | }, { 513 | "in" : "body", 514 | "name" : "body", 515 | "description" : "Updated user object", 516 | "required" : true, 517 | "schema" : { 518 | "$ref" : "#/definitions/User" 519 | } 520 | } ], 521 | "responses" : { 522 | "400" : { 523 | "description" : "Invalid user supplied" 524 | }, 525 | "404" : { 526 | "description" : "User not found" 527 | } 528 | } 529 | }, 530 | "delete" : { 531 | "tags" : [ "user" ], 532 | "summary" : "Delete user", 533 | "description" : "This can only be done by the logged in user.", 534 | "operationId" : "deleteUser", 535 | "produces" : [ "application/xml", "application/json" ], 536 | "parameters" : [ { 537 | "name" : "username", 538 | "in" : "path", 539 | "description" : "The name that needs to be deleted", 540 | "required" : true, 541 | "type" : "string" 542 | } ], 543 | "responses" : { 544 | "400" : { 545 | "description" : "Invalid username supplied" 546 | }, 547 | "404" : { 548 | "description" : "User not found" 549 | } 550 | } 551 | } 552 | } 553 | }, 554 | "securityDefinitions" : { 555 | "api_key" : { 556 | "type" : "apiKey", 557 | "name" : "api_key", 558 | "in" : "header" 559 | }, 560 | "petstore_auth" : { 561 | "type" : "oauth2", 562 | "authorizationUrl" : "http://swagger.io/api/oauth/dialog", 563 | "flow" : "implicit", 564 | "scopes" : { 565 | "write:pets" : "modify pets in your account", 566 | "read:pets" : "read your pets" 567 | } 568 | } 569 | }, 570 | "definitions" : { 571 | "Category" : { 572 | "type" : "object", 573 | "properties" : { 574 | "id" : { 575 | "type" : "integer", 576 | "format" : "int64" 577 | }, 578 | "name" : { 579 | "type" : "string" 580 | } 581 | }, 582 | "xml" : { 583 | "name" : "Category" 584 | } 585 | }, 586 | "Order" : { 587 | "type" : "object", 588 | "properties" : { 589 | "id" : { 590 | "type" : "integer", 591 | "format" : "int64" 592 | }, 593 | "petId" : { 594 | "type" : "integer", 595 | "format" : "int64" 596 | }, 597 | "quantity" : { 598 | "type" : "integer", 599 | "format" : "int32" 600 | }, 601 | "shipDate" : { 602 | "type" : "string", 603 | "format" : "date-time" 604 | }, 605 | "status" : { 606 | "type" : "string", 607 | "description" : "Order Status", 608 | "enum" : [ "placed", "approved", "delivered" ] 609 | }, 610 | "complete" : { 611 | "type" : "boolean", 612 | "default" : false 613 | } 614 | }, 615 | "xml" : { 616 | "name" : "Order" 617 | } 618 | }, 619 | "Pet" : { 620 | "type" : "object", 621 | "required" : [ "name", "photoUrls" ], 622 | "properties" : { 623 | "id" : { 624 | "type" : "integer", 625 | "format" : "int64" 626 | }, 627 | "category" : { 628 | "$ref" : "#/definitions/Category" 629 | }, 630 | "name" : { 631 | "type" : "string", 632 | "example" : "doggie" 633 | }, 634 | "photoUrls" : { 635 | "type" : "array", 636 | "xml" : { 637 | "name" : "photoUrl", 638 | "wrapped" : true 639 | }, 640 | "items" : { 641 | "type" : "string" 642 | } 643 | }, 644 | "tags" : { 645 | "type" : "array", 646 | "xml" : { 647 | "name" : "tag", 648 | "wrapped" : true 649 | }, 650 | "items" : { 651 | "$ref" : "#/definitions/Tag" 652 | } 653 | }, 654 | "status" : { 655 | "type" : "string", 656 | "description" : "pet status in the store", 657 | "enum" : [ "available", "pending", "sold" ] 658 | } 659 | }, 660 | "xml" : { 661 | "name" : "Pet" 662 | } 663 | }, 664 | "Tag" : { 665 | "type" : "object", 666 | "properties" : { 667 | "id" : { 668 | "type" : "integer", 669 | "format" : "int64" 670 | }, 671 | "name" : { 672 | "type" : "string" 673 | } 674 | }, 675 | "xml" : { 676 | "name" : "Tag" 677 | } 678 | }, 679 | "User" : { 680 | "type" : "object", 681 | "properties" : { 682 | "id" : { 683 | "type" : "integer", 684 | "format" : "int64" 685 | }, 686 | "username" : { 687 | "type" : "string" 688 | }, 689 | "firstName" : { 690 | "type" : "string" 691 | }, 692 | "lastName" : { 693 | "type" : "string" 694 | }, 695 | "email" : { 696 | "type" : "string" 697 | }, 698 | "password" : { 699 | "type" : "string" 700 | }, 701 | "phone" : { 702 | "type" : "string" 703 | }, 704 | "userStatus" : { 705 | "type" : "integer", 706 | "format" : "int32", 707 | "description" : "User Status" 708 | } 709 | }, 710 | "xml" : { 711 | "name" : "User" 712 | } 713 | } 714 | } 715 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | swagger-maven-example 8 | swagger-maven-example 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | 13 | 14 | com.github.kongchen 15 | swagger-maven-plugin 16 | 3.1.1 17 | 18 | 19 | 20 | false 21 | com.github.kongchen.swagger.sample.wordnik.resource 22 | http,https 23 | petstore.swagger.wordnik.com 24 | /api 25 | 26 | Swagger Maven Plugin Sample 27 | v1 28 | This is a sample for swagger-maven-plugin 29 | 30 | http://www.github.com/kongchen/swagger-maven-plugin 31 | 32 | 33 | kongchen@gmail.com 34 | Kong Chen 35 | http://kongch.com 36 | 37 | 38 | http://www.apache.org/licenses/LICENSE-2.0.html 39 | Apache 2.0 40 | 41 | 42 | 46 | ${basedir}/templates/strapdown.html.hbs 47 | ${basedir}/generated/document.html 48 | generated/swagger-ui 49 | 50 | 51 | /securityDefinitions.json 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | compile 60 | 61 | generate 62 | 63 | 64 | 65 | 66 | 67 | org.apache.maven.plugins 68 | maven-war-plugin 69 | 2.1.1 70 | 71 | 72 | org.apache.maven.plugins 73 | maven-compiler-plugin 74 | 3.1 75 | 76 | 1.6 77 | 1.6 78 | 79 | 80 | 81 | 82 | 83 | 84 | io.swagger 85 | swagger-core 86 | compile 87 | 1.5.3 88 | 89 | 90 | javax.ws.rs 91 | jsr311-api 92 | 93 | 94 | 95 | 96 | ch.qos.logback 97 | logback-classic 98 | ${logback-version} 99 | compile 100 | 101 | 102 | ch.qos.logback 103 | logback-core 104 | ${logback-version} 105 | compile 106 | 107 | 108 | javax.servlet 109 | servlet-api 110 | 2.5 111 | 112 | 113 | org.glassfish.jersey.containers 114 | jersey-container-servlet-core 115 | ${jersey2-version} 116 | 117 | 118 | org.glassfish.jersey.media 119 | jersey-media-multipart 120 | ${jersey2-version} 121 | 122 | 123 | 124 | 9.0.7.v20131107 125 | 2.4.1 126 | 1.0.1 127 | 128 | 129 | 130 | sonatype-snapshot 131 | https://oss.sonatype.org/content/repositories/snapshots/ 132 | 133 | false 134 | 135 | 136 | true 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/data/PetData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.data; 18 | 19 | import com.github.kongchen.swagger.sample.wordnik.model.Category; 20 | import com.github.kongchen.swagger.sample.wordnik.model.Pet; 21 | import com.github.kongchen.swagger.sample.wordnik.model.Tag; 22 | 23 | import java.util.List; 24 | import java.util.ArrayList; 25 | 26 | public class PetData { 27 | static List pets = new ArrayList(); 28 | static List categories = new ArrayList(); 29 | 30 | static { 31 | categories.add(createCategory(1, "Dogs")); 32 | categories.add(createCategory(2, "Cats")); 33 | categories.add(createCategory(3, "Rabbits")); 34 | categories.add(createCategory(4, "Lions")); 35 | 36 | pets.add(createPet(1, categories.get(1), "Cat 1", new String[] { 37 | "url1", "url2" }, new String[] { "tag1", "tag2" }, "available")); 38 | pets.add(createPet(2, categories.get(1), "Cat 2", new String[] { 39 | "url1", "url2" }, new String[] { "tag2", "tag3" }, "available")); 40 | pets.add(createPet(3, categories.get(1), "Cat 3", new String[] { 41 | "url1", "url2" }, new String[] { "tag3", "tag4" }, "pending")); 42 | 43 | pets.add(createPet(4, categories.get(0), "Dog 1", new String[] { 44 | "url1", "url2" }, new String[] { "tag1", "tag2" }, "available")); 45 | pets.add(createPet(5, categories.get(0), "Dog 2", new String[] { 46 | "url1", "url2" }, new String[] { "tag2", "tag3" }, "sold")); 47 | pets.add(createPet(6, categories.get(0), "Dog 3", new String[] { 48 | "url1", "url2" }, new String[] { "tag3", "tag4" }, "pending")); 49 | 50 | pets.add(createPet(7, categories.get(3), "Lion 1", new String[] { 51 | "url1", "url2" }, new String[] { "tag1", "tag2" }, "available")); 52 | pets.add(createPet(8, categories.get(3), "Lion 2", new String[] { 53 | "url1", "url2" }, new String[] { "tag2", "tag3" }, "available")); 54 | pets.add(createPet(9, categories.get(3), "Lion 3", new String[] { 55 | "url1", "url2" }, new String[] { "tag3", "tag4" }, "available")); 56 | 57 | pets.add(createPet(10, categories.get(2), "Rabbit 1", new String[] { 58 | "url1", "url2" }, new String[] { "tag3", "tag4" }, "available")); 59 | } 60 | 61 | public Pet getPetbyId(long petId) { 62 | for (Pet pet : pets) { 63 | if (pet.getId() == petId) { 64 | return pet; 65 | } 66 | } 67 | return null; 68 | } 69 | 70 | public void deletePet(long petId) { 71 | if(pets.size() > 0) { 72 | for (int i = pets.size(); i >= 0; i++) { 73 | Pet pet = pets.get(i); 74 | if(pet.getId() == petId) { 75 | pets.remove(i); 76 | } 77 | } 78 | } 79 | } 80 | 81 | public List findPetByStatus(String status) { 82 | String[] statues = status.split(","); 83 | List result = new java.util.ArrayList(); 84 | for (Pet pet : pets) { 85 | for (String s : statues) { 86 | if (s.equals(pet.getStatus())) { 87 | result.add(pet); 88 | } 89 | } 90 | } 91 | return result; 92 | } 93 | 94 | public List findPetByTags(String tags) { 95 | String[] tagList = tags.split(","); 96 | List result = new java.util.ArrayList(); 97 | for (Pet pet : pets) { 98 | if (null != pet.getTags()) { 99 | for (Tag tag : pet.getTags()) { 100 | for (String tagListString : tagList) { 101 | if (tagListString.equals(tag.getName())) 102 | result.add(pet); 103 | } 104 | } 105 | } 106 | } 107 | return result; 108 | } 109 | 110 | public Pet addPet(Pet pet) { 111 | if(pet.getId() == 0) { 112 | long maxId = 0; 113 | for (int i = pets.size() - 1; i >= 0; i--) { 114 | if(pets.get(i).getId() > maxId) { 115 | maxId = pets.get(i).getId(); 116 | } 117 | } 118 | pet.setId(maxId + 1); 119 | } 120 | if (pets.size() > 0) { 121 | for (int i = pets.size() - 1; i >= 0; i--) { 122 | if (pets.get(i).getId() == pet.getId()) { 123 | pets.remove(i); 124 | } 125 | } 126 | } 127 | pets.add(pet); 128 | return pet; 129 | } 130 | 131 | static Pet createPet(long id, Category cat, String name, String[] urls, 132 | String[] tags, String status) { 133 | Pet pet = new Pet(); 134 | pet.setId(id); 135 | pet.setCategory(cat); 136 | pet.setName(name); 137 | if (null != urls) { 138 | List urlObjs = new ArrayList(); 139 | for (String urlString : urls) { 140 | urlObjs.add(urlString); 141 | } 142 | pet.setPhotoUrls(urlObjs); 143 | } 144 | List tagObjs = new java.util.ArrayList(); 145 | int i = 0; 146 | if (null != tags) { 147 | for (String tagString : tags) { 148 | i = i + 1; 149 | Tag tag = new Tag(); 150 | tag.setId(i); 151 | tag.setName(tagString); 152 | tagObjs.add(tag); 153 | } 154 | } 155 | pet.setTags(tagObjs); 156 | pet.setStatus(status); 157 | return pet; 158 | } 159 | 160 | static Category createCategory(long id, String name) { 161 | Category category = new Category(); 162 | category.setId(id); 163 | category.setName(name); 164 | return category; 165 | } 166 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/data/StoreData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.data; 18 | 19 | import com.github.kongchen.swagger.sample.wordnik.model.Order; 20 | 21 | import java.util.Date; 22 | import java.util.List; 23 | import java.util.ArrayList; 24 | 25 | public class StoreData { 26 | static List orders = new ArrayList(); 27 | 28 | static { 29 | orders.add(createOrder(1, 1, 2, new Date(), "placed")); 30 | orders.add(createOrder(2, 1, 2, new Date(), "delivered")); 31 | orders.add(createOrder(3, 2, 2, new Date(), "placed")); 32 | orders.add(createOrder(4, 2, 2, new Date(), "delivered")); 33 | orders.add(createOrder(5, 3, 2, new Date(), "placed")); 34 | orders.add(createOrder(11, 3, 2, new Date(), "placed")); 35 | orders.add(createOrder(12, 3, 2, new Date(), "placed")); 36 | orders.add(createOrder(13, 3, 2, new Date(), "placed")); 37 | orders.add(createOrder(14, 3, 2, new Date(), "placed")); 38 | orders.add(createOrder(15, 3, 2, new Date(), "placed")); 39 | } 40 | 41 | public Order findOrderById(long orderId) { 42 | for (Order order : orders) { 43 | if (order.getId() == orderId) { 44 | return order; 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | public Order placeOrder(Order order) { 51 | if (orders.size() > 0) { 52 | for (int i = orders.size() - 1; i >= 0; i--) { 53 | if (orders.get(i).getId() == order.getId()) { 54 | orders.remove(i); 55 | } 56 | } 57 | } 58 | orders.add(order); 59 | return order; 60 | } 61 | 62 | public void deleteOrder(long orderId) { 63 | if (orders.size() > 0) { 64 | for (int i = orders.size() - 1; i >= 0; i--) { 65 | if (orders.get(i).getId() == orderId) { 66 | orders.remove(i); 67 | } 68 | } 69 | } 70 | } 71 | 72 | private static Order createOrder(long id, long petId, int quantity, 73 | Date shipDate, String status) { 74 | Order order = new Order(); 75 | order.setId(id); 76 | order.setPetId(petId); 77 | order.setQuantity(quantity); 78 | order.setShipDate(shipDate); 79 | order.setStatus(status); 80 | return order; 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/data/UserData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.data; 18 | 19 | import com.github.kongchen.swagger.sample.wordnik.model.User; 20 | 21 | import java.util.List; 22 | import java.util.ArrayList; 23 | 24 | public class UserData { 25 | static List users = new ArrayList(); 26 | 27 | static { 28 | users.add(createUser(1, "user1", "first name 1", "last name 1", 29 | "email1@test.com", "123-456-7890", 1)); 30 | users.add(createUser(2, "user2", "first name 2", "last name 2", 31 | "email2@test.com", "123-456-7890", 2)); 32 | users.add(createUser(3, "user3", "first name 3", "last name 3", 33 | "email3@test.com", "123-456-7890", 3)); 34 | users.add(createUser(4, "user4", "first name 4", "last name 4", 35 | "email4@test.com", "123-456-7890", 1)); 36 | users.add(createUser(5, "user5", "first name 5", "last name 5", 37 | "email5@test.com", "123-456-7890", 2)); 38 | users.add(createUser(6, "user6", "first name 6", "last name 6", 39 | "email6@test.com", "123-456-7890", 3)); 40 | users.add(createUser(7, "user7", "first name 7", "last name 7", 41 | "email7@test.com", "123-456-7890", 1)); 42 | users.add(createUser(8, "user8", "first name 8", "last name 8", 43 | "email8@test.com", "123-456-7890", 2)); 44 | users.add(createUser(9, "user9", "first name 9", "last name 9", 45 | "email9@test.com", "123-456-7890", 3)); 46 | users.add(createUser(10, "user10", "first name 10", "last name 10", 47 | "email10@test.com", "123-456-7890", 1)); 48 | users.add(createUser(11, "user?10", "first name ?10", "last name ?10", 49 | "email101@test.com", "123-456-7890", 1)); 50 | 51 | } 52 | 53 | public User findUserByName(String username) { 54 | for (User user : users) { 55 | if (user.getUsername().equals(username)) { 56 | return user; 57 | } 58 | } 59 | return null; 60 | } 61 | 62 | public void addUser(User user) { 63 | if (users.size() > 0) { 64 | for (int i = users.size() - 1; i >= 0; i--) { 65 | if (users.get(i).getUsername().equals(user.getUsername())) { 66 | users.remove(i); 67 | } 68 | } 69 | } 70 | users.add(user); 71 | } 72 | 73 | public void removeUser(String username) { 74 | if (users.size() > 0) { 75 | for (int i = users.size() - 1; i >= 0; i--) { 76 | if (users.get(i).getUsername().equals(username)) { 77 | users.remove(i); 78 | } 79 | } 80 | } 81 | } 82 | 83 | private static User createUser(long id, String username, String firstName, 84 | String lastName, String email, String phone, int userStatus) { 85 | User user = new User(); 86 | user.setId(id); 87 | user.setUsername(username); 88 | user.setFirstName(firstName); 89 | user.setLastName(lastName); 90 | user.setEmail(email); 91 | user.setPassword("XXXXXXXXXXX"); 92 | user.setPhone(phone); 93 | user.setUserStatus(userStatus); 94 | return user; 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/exception/ApiException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.exception; 18 | 19 | public class ApiException extends Exception{ 20 | private int code; 21 | public ApiException (int code, String msg) { 22 | super(msg); 23 | this.code = code; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.exception; 18 | 19 | public class BadRequestException extends ApiException{ 20 | private int code; 21 | public BadRequestException (int code, String msg) { 22 | super(code, msg); 23 | this.code = code; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/exception/NotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.exception; 18 | 19 | public class NotFoundException extends ApiException { 20 | private int code; 21 | public NotFoundException (int code, String msg) { 22 | super(code, msg); 23 | this.code = code; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/ApiResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import javax.xml.bind.annotation.XmlTransient; 20 | 21 | @javax.xml.bind.annotation.XmlRootElement 22 | public class ApiResponse { 23 | public static final int ERROR = 1; 24 | public static final int WARNING = 2; 25 | public static final int INFO = 3; 26 | public static final int OK = 4; 27 | public static final int TOO_BUSY = 5; 28 | 29 | int code; 30 | String type; 31 | String message; 32 | 33 | public ApiResponse(){} 34 | 35 | public ApiResponse(int code, String message){ 36 | this.code = code; 37 | switch(code){ 38 | case ERROR: 39 | setType("error"); 40 | break; 41 | case WARNING: 42 | setType("warning"); 43 | break; 44 | case INFO: 45 | setType("info"); 46 | break; 47 | case OK: 48 | setType("ok"); 49 | break; 50 | case TOO_BUSY: 51 | setType("too busy"); 52 | break; 53 | default: 54 | setType("unknown"); 55 | break; 56 | } 57 | this.message = message; 58 | } 59 | 60 | @XmlTransient 61 | public int getCode() { 62 | return code; 63 | } 64 | 65 | public void setCode(int code) { 66 | this.code = code; 67 | } 68 | 69 | public String getType() { 70 | return type; 71 | } 72 | 73 | public void setType(String type) { 74 | this.type = type; 75 | } 76 | 77 | public String getMessage() { 78 | return message; 79 | } 80 | 81 | public void setMessage(String message) { 82 | this.message = message; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Category.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import javax.xml.bind.annotation.*; 20 | 21 | @XmlRootElement(name = "Category") 22 | public class Category { 23 | private long id; 24 | private String name; 25 | 26 | @XmlElement(name = "id") 27 | public long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(long id) { 32 | this.id = id; 33 | } 34 | 35 | @XmlElement(name = "name") 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Order.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import io.swagger.annotations.*; 20 | 21 | import java.util.Date; 22 | 23 | import javax.xml.bind.annotation.*; 24 | 25 | @XmlRootElement(name = "Order") 26 | public class Order { 27 | private long id; 28 | private long petId; 29 | private int quantity; 30 | private Date shipDate; 31 | private String status; 32 | private boolean complete; 33 | 34 | @XmlElement(name = "id") 35 | public long getId() { 36 | return id; 37 | } 38 | 39 | public void setId(long id) { 40 | this.id = id; 41 | } 42 | 43 | public boolean isComplete() { 44 | return complete; 45 | } 46 | 47 | public void setComplete(boolean complete) { 48 | this.complete = complete; 49 | } 50 | 51 | @XmlElement(name = "petId") 52 | public long getPetId() { 53 | return petId; 54 | } 55 | 56 | public void setPetId(long petId) { 57 | this.petId = petId; 58 | } 59 | 60 | @XmlElement(name = "quantity") 61 | public int getQuantity() { 62 | return quantity; 63 | } 64 | 65 | public void setQuantity(int quantity) { 66 | this.quantity = quantity; 67 | } 68 | 69 | @XmlElement(name = "status") 70 | @ApiModelProperty(value = "Order Status", allowableValues = "placed, approved, delivered") 71 | public String getStatus() { 72 | return status; 73 | } 74 | 75 | public void setStatus(String status) { 76 | this.status = status; 77 | } 78 | 79 | @XmlElement(name = "shipDate") 80 | public Date getShipDate() { 81 | return shipDate; 82 | } 83 | 84 | public void setShipDate(Date shipDate) { 85 | this.shipDate = shipDate; 86 | } 87 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Pet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import io.swagger.annotations.*; 20 | 21 | import java.util.List; 22 | import java.util.ArrayList; 23 | 24 | import javax.xml.bind.annotation.*; 25 | 26 | @XmlRootElement(name = "Pet") 27 | public class Pet { 28 | private long id; 29 | private Category category; 30 | private String name; 31 | private List photoUrls = new ArrayList(); 32 | private List tags = new ArrayList(); 33 | private String status; 34 | 35 | @XmlElement(name = "id") 36 | public long getId() { 37 | return id; 38 | } 39 | 40 | public void setId(long id) { 41 | this.id = id; 42 | } 43 | 44 | @XmlElement(name = "category") 45 | public Category getCategory() { 46 | return category; 47 | } 48 | 49 | public void setCategory(Category category) { 50 | this.category = category; 51 | } 52 | 53 | @XmlElement(name = "name") 54 | @ApiModelProperty(example = "doggie", required = true) 55 | public String getName() { 56 | return name; 57 | } 58 | 59 | public void setName(String name) { 60 | this.name = name; 61 | } 62 | 63 | @XmlElementWrapper(name = "photoUrls") 64 | @XmlElement(name = "photoUrl", required = true) 65 | public List getPhotoUrls() { 66 | return photoUrls; 67 | } 68 | 69 | public void setPhotoUrls(List photoUrls) { 70 | this.photoUrls = photoUrls; 71 | } 72 | 73 | @XmlElementWrapper(name = "tags") 74 | @XmlElement(name = "tag") 75 | public List getTags() { 76 | return tags; 77 | } 78 | 79 | public void setTags(List tags) { 80 | this.tags = tags; 81 | } 82 | 83 | @XmlElement(name = "status") 84 | @ApiModelProperty(value = "pet status in the store", allowableValues = "available,pending,sold") 85 | public String getStatus() { 86 | return status; 87 | } 88 | 89 | public void setStatus(String status) { 90 | this.status = status; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Tag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import javax.xml.bind.annotation.*; 20 | 21 | @XmlRootElement(name = "Tag") 22 | public class Tag { 23 | private long id; 24 | private String name; 25 | 26 | @XmlElement(name = "id") 27 | public long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(long id) { 32 | this.id = id; 33 | } 34 | 35 | @XmlElement(name = "name") 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/model/User.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.model; 18 | 19 | import io.swagger.annotations.*; 20 | 21 | import javax.xml.bind.annotation.*; 22 | 23 | @XmlRootElement(name = "User") 24 | public class User { 25 | private long id; 26 | private String username; 27 | private String firstName; 28 | private String lastName; 29 | private String email; 30 | private String password; 31 | private String phone; 32 | private int userStatus; 33 | 34 | @XmlElement(name = "id") 35 | public long getId() { 36 | return id; 37 | } 38 | 39 | public void setId(long id) { 40 | this.id = id; 41 | } 42 | 43 | @XmlElement(name = "firstName") 44 | public String getFirstName() { 45 | return firstName; 46 | } 47 | 48 | public void setFirstName(String firstName) { 49 | this.firstName = firstName; 50 | } 51 | 52 | @XmlElement(name = "username") 53 | public String getUsername() { 54 | return username; 55 | } 56 | 57 | public void setUsername(String username) { 58 | this.username = username; 59 | } 60 | 61 | @XmlElement(name = "lastName") 62 | public String getLastName() { 63 | return lastName; 64 | } 65 | 66 | public void setLastName(String lastName) { 67 | this.lastName = lastName; 68 | } 69 | 70 | @XmlElement(name = "email") 71 | public String getEmail() { 72 | return email; 73 | } 74 | 75 | public void setEmail(String email) { 76 | this.email = email; 77 | } 78 | 79 | @XmlElement(name = "password") 80 | public String getPassword() { 81 | return password; 82 | } 83 | 84 | public void setPassword(String password) { 85 | this.password = password; 86 | } 87 | 88 | @XmlElement(name = "phone") 89 | public String getPhone() { 90 | return phone; 91 | } 92 | 93 | public void setPhone(String phone) { 94 | this.phone = phone; 95 | } 96 | 97 | @XmlElement(name = "userStatus") 98 | @ApiModelProperty(value = "User Status", allowableValues = "1-registered,2-active,3-closed") 99 | public int getUserStatus() { 100 | return userStatus; 101 | } 102 | 103 | public void setUserStatus(int userStatus) { 104 | this.userStatus = userStatus; 105 | } 106 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/JavaRestResourceUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.resource; 18 | 19 | import java.text.SimpleDateFormat; 20 | 21 | import java.util.Date; 22 | 23 | public class JavaRestResourceUtil { 24 | public int getInt(int minVal, int maxVal, int defaultValue, String inputString) { 25 | int output = defaultValue; 26 | try { 27 | output = Integer.parseInt(inputString); 28 | } 29 | catch (Exception e){ 30 | output = defaultValue; 31 | } 32 | 33 | if (output < minVal) output = minVal; 34 | if (maxVal == -1) { 35 | if (output < minVal) output = minVal; 36 | } 37 | else if (output > maxVal) output = maxVal; 38 | return output; 39 | } 40 | 41 | public long getLong(long minVal, long maxVal, long defaultValue, String inputString) { 42 | long output = defaultValue; 43 | try { 44 | output = Long.parseLong(inputString); 45 | } 46 | catch (Exception e){ 47 | output = defaultValue; 48 | } 49 | 50 | if (output < minVal) output = minVal; 51 | if (maxVal == -1) { if (output < minVal) output = minVal; } 52 | else if (output > maxVal) output = maxVal; 53 | return output; 54 | } 55 | 56 | public double getDouble(double minVal, double maxVal, double defaultValue, String inputString) { 57 | double output = defaultValue; 58 | try { 59 | output = Double.parseDouble(inputString); 60 | } 61 | catch (Exception e){ 62 | output = defaultValue; 63 | } 64 | 65 | if (output < minVal) output = minVal; 66 | if (maxVal == -1) { 67 | if (output < minVal) output = minVal; 68 | } 69 | else if (output > maxVal) output = maxVal; 70 | return output; 71 | } 72 | 73 | public boolean getBoolean(boolean defaultValue, String booleanString) { 74 | boolean output = defaultValue; 75 | if (booleanString == null) output = defaultValue; 76 | 77 | // treat "", "YES" as "true" 78 | if ("".equals(booleanString)) output = true; 79 | else if ("YES".equalsIgnoreCase(booleanString)) output = true; 80 | else if ("NO".equalsIgnoreCase(booleanString)) output = false; 81 | else { 82 | try { 83 | output = Boolean.parseBoolean(booleanString); 84 | } 85 | catch (Exception e){ 86 | output = defaultValue; 87 | } 88 | } 89 | return output; 90 | } 91 | 92 | public Date getDate(Date defaultValue, String dateString){ 93 | try { 94 | return new SimpleDateFormat("yyyy-MM-dd").parse(dateString); 95 | } 96 | catch(Exception e) { 97 | return defaultValue; 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetResource.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.resource; 18 | 19 | import com.github.kongchen.swagger.sample.wordnik.data.PetData; 20 | import io.swagger.annotations.*; 21 | import com.github.kongchen.swagger.sample.wordnik.model.Pet; 22 | import io.swagger.annotations.ApiResponse; 23 | 24 | import javax.ws.rs.core.Response; 25 | import javax.ws.rs.core.MediaType; 26 | import javax.ws.rs.*; 27 | 28 | @Path("/pet") 29 | @Api(value = "/pet", description = "Operations about pets", authorizations = { 30 | @Authorization(value = "petstore_auth", 31 | scopes = { 32 | @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), 33 | @AuthorizationScope(scope = "read:pets", description = "read your pets") 34 | }) 35 | }) 36 | @Produces({"application/json", "application/xml"}) 37 | public class PetResource { 38 | static PetData petData = new PetData(); 39 | static JavaRestResourceUtil ru = new JavaRestResourceUtil(); 40 | 41 | @GET 42 | @Path("/{petId}") 43 | @ApiOperation(value = "Find pet by ID", 44 | notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", 45 | response = Pet.class, 46 | authorizations = @Authorization(value = "api_key") 47 | ) 48 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), 49 | @ApiResponse(code = 404, message = "Pet not found") }) 50 | public Response getPetById( 51 | @ApiParam(value = "ID of pet that needs to be fetched", allowableValues = "range[1,5]", required = true) @PathParam("petId") Long petId) 52 | throws com.github.kongchen.swagger.sample.wordnik.exception.NotFoundException { 53 | Pet pet = petData.getPetbyId(petId); 54 | if (null != pet) { 55 | return Response.ok().entity(pet).build(); 56 | } else { 57 | throw new com.github.kongchen.swagger.sample.wordnik.exception.NotFoundException(404, "Pet not found"); 58 | } 59 | } 60 | 61 | @DELETE 62 | @Path("/{petId}") 63 | @ApiOperation(value = "Deletes a pet") 64 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value")}) 65 | public Response deletePet( 66 | @ApiParam() @HeaderParam("api_key") String apiKey, 67 | @ApiParam(value = "Pet id to delete", required = true)@PathParam("petId") Long petId) { 68 | petData.deletePet(petId); 69 | return Response.ok().build(); 70 | } 71 | 72 | @POST 73 | @Consumes({"application/json", "application/xml"}) 74 | @ApiOperation(value = "Add a new pet to the store") 75 | @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) 76 | public Response addPet( 77 | @ApiParam(value = "Pet object that needs to be added to the store", required = true) Pet pet) { 78 | Pet updatedPet = petData.addPet(pet); 79 | return Response.ok().entity(updatedPet).build(); 80 | } 81 | 82 | @PUT 83 | @Consumes({"application/json", "application/xml"}) 84 | @ApiOperation(value = "Update an existing pet") 85 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), 86 | @ApiResponse(code = 404, message = "Pet not found"), 87 | @ApiResponse(code = 405, message = "Validation exception") }) 88 | public Response updatePet( 89 | @ApiParam(value = "Pet object that needs to be added to the store", required = true) Pet pet) { 90 | Pet updatedPet = petData.addPet(pet); 91 | return Response.ok().entity(updatedPet).build(); 92 | } 93 | 94 | @GET 95 | @Path("/findByStatus") 96 | @ApiOperation(value = "Finds Pets by status", 97 | notes = "Multiple status values can be provided with comma seperated strings", 98 | response = Pet.class, 99 | responseContainer = "List") 100 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid status value") }) 101 | public Response findPetsByStatus( 102 | @ApiParam(value = "Status values that need to be considered for filter", required = true, defaultValue = "available", allowableValues = "available,pending,sold", allowMultiple = true) @QueryParam("status") String status) { 103 | return Response.ok(petData.findPetByStatus(status)).build(); 104 | } 105 | 106 | @GET 107 | @Path("/findByTags") 108 | @ApiOperation(value = "Finds Pets by tags", 109 | notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", 110 | response = Pet.class, 111 | responseContainer = "List") 112 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tag value") }) 113 | @Deprecated 114 | public Response findPetsByTags( 115 | @ApiParam(value = "Tags to filter by", required = true, allowMultiple = true) @QueryParam("tags") String tags) { 116 | return Response.ok(petData.findPetByTags(tags)).build(); 117 | } 118 | 119 | @POST 120 | @Path("/{petId}") 121 | @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) 122 | @ApiOperation(value = "Updates a pet in the store with form data", 123 | consumes = MediaType.APPLICATION_FORM_URLENCODED) 124 | @ApiResponses(value = { 125 | @ApiResponse(code = 405, message = "Invalid input")}) 126 | public Response updatePetWithForm ( 127 | @ApiParam(value = "ID of pet that needs to be updated", required = true)@PathParam("petId") String petId, 128 | @ApiParam(value = "Updated name of the pet", required = false)@FormParam("name") String name, 129 | @ApiParam(value = "Updated status of the pet", required = false)@FormParam("status") String status) { 130 | System.out.println(name); 131 | System.out.println(status); 132 | return Response.ok().entity(new com.github.kongchen.swagger.sample.wordnik.model.ApiResponse(200, "SUCCESS")).build(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetStoreResource.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.resource; 18 | 19 | import io.swagger.annotations.*; 20 | import com.github.kongchen.swagger.sample.wordnik.data.StoreData; 21 | import com.github.kongchen.swagger.sample.wordnik.model.Order; 22 | import com.github.kongchen.swagger.sample.wordnik.exception.NotFoundException; 23 | 24 | import javax.ws.rs.core.Response; 25 | import javax.ws.rs.*; 26 | 27 | @Path("/store") 28 | @Api(value="/store" , description = "Operations about store") 29 | @Produces({"application/json", "application/xml"}) 30 | public class PetStoreResource { 31 | static StoreData storeData = new StoreData(); 32 | static JavaRestResourceUtil ru = new JavaRestResourceUtil(); 33 | 34 | @GET 35 | @Path("/order/{orderId}") 36 | @ApiOperation(value = "Find purchase order by ID", 37 | notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", 38 | response = Order.class) 39 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), 40 | @ApiResponse(code = 404, message = "Order not found") }) 41 | public Response getOrderById( 42 | @ApiParam(value = "ID of pet that needs to be fetched", allowableValues = "range[1,5]", required = true) @PathParam("orderId") String orderId) 43 | throws NotFoundException { 44 | Order order = storeData.findOrderById(ru.getLong(0, 10000, 0, orderId)); 45 | if (null != order) { 46 | return Response.ok().entity(order).build(); 47 | } else { 48 | throw new NotFoundException(404, "Order not found"); 49 | } 50 | } 51 | 52 | @POST 53 | @Path("/order") 54 | @ApiOperation(value = "Place an order for a pet") 55 | @ApiResponses({ @ApiResponse(code = 400, message = "Invalid Order") }) 56 | public Order placeOrder( 57 | @ApiParam(value = "order placed for purchasing the pet", 58 | required = true) Order order) { 59 | storeData.placeOrder(order); 60 | return storeData.placeOrder(order); 61 | } 62 | 63 | @DELETE 64 | @Path("/order/{orderId}") 65 | @ApiOperation(value = "Delete purchase order by ID", 66 | notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors") 67 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), 68 | @ApiResponse(code = 404, message = "Order not found") }) 69 | public Response deleteOrder( 70 | @ApiParam(value = "ID of the order that needs to be deleted", allowableValues = "range[1,infinity]", required = true) @PathParam("orderId") String orderId) { 71 | storeData.deleteOrder(ru.getLong(0, 10000, 0, orderId)); 72 | return Response.ok().entity("").build(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/UserResource.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Reverb Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.github.kongchen.swagger.sample.wordnik.resource; 18 | 19 | import io.swagger.annotations.*; 20 | import com.github.kongchen.swagger.sample.wordnik.data.UserData; 21 | import com.github.kongchen.swagger.sample.wordnik.model.User; 22 | import com.github.kongchen.swagger.sample.wordnik.exception.ApiException; 23 | 24 | import javax.ws.rs.core.Response; 25 | import javax.ws.rs.*; 26 | 27 | @Path("/user") 28 | @Api(value="/user", description = "Operations about user") 29 | @Produces({"application/json", "application/xml"}) 30 | public class UserResource { 31 | static UserData userData = new UserData(); 32 | 33 | @POST 34 | @ApiOperation(value = "Create user", 35 | notes = "This can only be done by the logged in user.", 36 | position = 1) 37 | public Response createUser( 38 | @ApiParam(value = "Created user object", required = true) User user) { 39 | userData.addUser(user); 40 | return Response.ok().entity("").build(); 41 | } 42 | 43 | @POST 44 | @Path("/createWithArray") 45 | @ApiOperation(value = "Creates list of users with given input array", 46 | position = 2) 47 | public Response createUsersWithArrayInput(@ApiParam(value = "List of user object", required = true) User[] users) { 48 | for (User user : users) { 49 | userData.addUser(user); 50 | } 51 | return Response.ok().entity("").build(); 52 | } 53 | 54 | @POST 55 | @Path("/createWithList") 56 | @ApiOperation(value = "Creates list of users with given input array", 57 | position = 3) 58 | public Response createUsersWithListInput(@ApiParam(value = "List of user object", required = true) java.util.List users) { 59 | for (User user : users) { 60 | userData.addUser(user); 61 | } 62 | return Response.ok().entity("").build(); 63 | } 64 | 65 | @PUT 66 | @Path("/{username}") 67 | @ApiOperation(value = "Updated user", 68 | notes = "This can only be done by the logged in user.", 69 | position = 4) 70 | @ApiResponses(value = { 71 | @ApiResponse(code = 400, message = "Invalid user supplied"), 72 | @ApiResponse(code = 404, message = "User not found") }) 73 | public Response updateUser( 74 | @ApiParam(value = "name that need to be deleted", required = true) @PathParam("username") String username, 75 | @ApiParam(value = "Updated user object", required = true) User user) { 76 | userData.addUser(user); 77 | return Response.ok().entity("").build(); 78 | } 79 | 80 | @DELETE 81 | @Path("/{username}") 82 | @ApiOperation(value = "Delete user", 83 | notes = "This can only be done by the logged in user.", 84 | position = 5) 85 | @ApiResponses(value = { 86 | @ApiResponse(code = 400, message = "Invalid username supplied"), 87 | @ApiResponse(code = 404, message = "User not found") }) 88 | public Response deleteUser( 89 | @ApiParam(value = "The name that needs to be deleted", required = true) @PathParam("username") String username) { 90 | userData.removeUser(username); 91 | return Response.ok().entity("").build(); 92 | } 93 | 94 | @GET 95 | @Path("/{username}") 96 | @ApiOperation(value = "Get user by user name", 97 | response = User.class, 98 | position = 0) 99 | @ApiResponses(value = { 100 | @ApiResponse(code = 400, message = "Invalid username supplied"), 101 | @ApiResponse(code = 404, message = "User not found") }) 102 | public Response getUserByName( 103 | @ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ", required = true) @PathParam("username") String username) 104 | throws ApiException { 105 | User user = userData.findUserByName(username); 106 | if (null != user) { 107 | return Response.ok().entity(user).build(); 108 | } else { 109 | throw new com.github.kongchen.swagger.sample.wordnik.exception.NotFoundException(404, "User not found"); 110 | } 111 | } 112 | 113 | @GET 114 | @Path("/login") 115 | @ApiOperation(value = "Logs user into the system", 116 | response = String.class, 117 | position = 6) 118 | @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) 119 | public Response loginUser( 120 | @ApiParam(value = "The user name for login", required = true) @QueryParam("username") String username, 121 | @ApiParam(value = "The password for login in clear text", required = true) @QueryParam("password") String password) { 122 | return Response.ok() 123 | .entity("logged in user session:" + System.currentTimeMillis()) 124 | .build(); 125 | } 126 | 127 | @GET 128 | @Path("/logout") 129 | @ApiOperation(value = "Logs out current logged in user session", 130 | position = 7) 131 | public Response logoutUser() { 132 | return Response.ok().entity("").build(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/securityDefinitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_key": { 3 | "type": "apiKey", 4 | "name": "api_key", 5 | "in": "header" 6 | }, 7 | "petstore_auth": { 8 | "type": "oauth2", 9 | "authorizationUrl": "http://swagger.io/api/oauth/dialog", 10 | "flow": "implicit", 11 | "scopes": { 12 | "write:pets": "modify pets in your account", 13 | "read:pets": "read your pets" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | jersey 8 | org.glassfish.jersey.servlet.ServletContainer 9 | 10 | jersey.config.server.provider.packages 11 | 12 | io.swagger.jaxrs.json, 13 | com.github.kongchen.swagger.sample.wordnik.resource 14 | 15 | 16 | 17 | jersey.config.server.provider.classnames 18 | 19 | io.swagger.jersey.listing.ApiListingResourceJSON, 20 | io.swagger.jersey.listing.JerseyApiDeclarationProvider, 21 | io.swagger.jersey.listing.JerseyResourceListingProvider 22 | 23 | 24 | 25 | jersey.config.server.wadl.disableWadl 26 | true 27 | 28 | 1 29 | 30 | 31 | 32 | jersey 33 | /api/* 34 | 35 | 36 | 37 | Jersey2Config 38 | io.swagger.jersey.config.JerseyJaxrsConfig 39 | 40 | api.version 41 | 1.0.0 42 | 43 | 44 | swagger.api.basepath 45 | http://localhost:8002/api 46 | 47 | 48 | swagger.filter 49 | com.github.kongchen.swagger.sample.wordnik.util.ApiAuthorizationFilterImpl 50 | 51 | 2 52 | 53 | 54 | 55 | ApiOriginFilter 56 | com.github.kongchen.swagger.sample.wordnik.util.ApiOriginFilter 57 | 58 | 59 | Bootstrap 60 | com.github.kongchen.swagger.sample.wordnik.Bootstrap 61 | 2 62 | 63 | 64 | ApiOriginFilter 65 | /* 66 | 67 | -------------------------------------------------------------------------------- /templates/markdown.hbs: -------------------------------------------------------------------------------- 1 | #{{#info}}{{title}} 2 | 3 | 4 | ## {{join schemes " | "}}://{{host}}{{basePath}} 5 | 6 | 7 | {{description}} 8 | 9 | {{#contact}} 10 | [**Contact the developer**](mailto:{{email}}) 11 | {{/contact}} 12 | 13 | **Version** {{version}} 14 | 15 | [**Terms of Service**]({{termsOfService}}) 16 | 17 | {{#license}}[**{{name}}**]({{url}}){{/license}} 18 | 19 | {{/info}} 20 | 21 | {{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}} 22 | 23 | {{#if produces}}**Produces:** {{join produces ", "}}{{/if}} 24 | 25 | {{#if securityDefinitions}} 26 | # Security Definitions 27 | {{/if}} 28 | {{> security}} 29 | 30 | # APIs 31 | 32 | {{#each paths}} 33 | ## {{@key}} 34 | {{#this}} 35 | {{#get}} 36 | ### GET 37 | {{> operation}} 38 | {{/get}} 39 | 40 | {{#put}} 41 | ### PUT 42 | {{> operation}} 43 | {{/put}} 44 | 45 | {{#post}} 46 | ### POST 47 | 48 | {{> operation}} 49 | 50 | {{/post}} 51 | 52 | {{#delete}} 53 | ### DELETE 54 | {{> operation}} 55 | {{/delete}} 56 | 57 | {{#option}} 58 | ### OPTION 59 | {{> operation}} 60 | {{/option}} 61 | 62 | {{#patch}} 63 | ### PATCH 64 | {{> operation}} 65 | {{/patch}} 66 | 67 | {{#head}} 68 | ### HEAD 69 | {{> operation}} 70 | {{/head}} 71 | 72 | {{/this}} 73 | {{/each}} 74 | 75 | # Definitions 76 | {{#each definitions}} 77 | ## {{@key}} 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | {{#each this.properties}} 88 | 89 | 90 | 101 | 102 | 103 | 104 | 105 | {{/each}} 106 |
nametyperequireddescriptionexample
{{@key}} 91 | {{#ifeq type "array"}} 92 | {{#items.$ref}} 93 | {{type}}[{{basename items.$ref}}] 94 | {{/items.$ref}} 95 | {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}} 96 | {{else}} 97 | {{#$ref}}{{basename $ref}}{{/$ref}} 98 | {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}} 99 | {{/ifeq}} 100 | {{#required}}required{{/required}}{{^required}}optional{{/required}}{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}{{example}}
107 | {{/each}} 108 | 109 | -------------------------------------------------------------------------------- /templates/operation.hbs: -------------------------------------------------------------------------------- 1 | {{#deprecated}}-deprecated-{{/deprecated}} 2 | {{summary}} 3 | 4 | {{description}} 5 | 6 | {{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}}) 7 | {{/if}} 8 | 9 | {{#if security}} 10 | #### Security 11 | {{/if}} 12 | 13 | {{#security}} 14 | {{#each this}} 15 | * {{@key}} 16 | {{#this}} * {{this}} 17 | {{/this}} 18 | {{/each}} 19 | {{/security}} 20 | 21 | #### Request 22 | 23 | {{#if consumes}} 24 | **Content-Type: ** {{join consumes ", "}}{{/if}} 25 | 26 | ##### Parameters 27 | {{#if parameters}} 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {{/if}} 38 | 39 | {{#parameters}} 40 | 41 | 42 | 43 | 44 | 45 | 46 | {{#ifeq in "body"}} 47 | 51 | {{else}} 52 | {{#ifeq type "array"}} 53 | 54 | {{else}} 55 | 56 | {{/ifeq}} 57 | {{/ifeq}} 58 | 59 | {{/parameters}} 60 | {{#if parameters}} 61 |
NameLocated inRequiredDescriptionDefaultSchema
{{name}}{{in}}{{#if required}}yes{{else}}no{{/if}}{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}} - 48 | {{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{/ifeq}} 49 | {{#schema.$ref}}{{basename schema.$ref}} {{/schema.$ref}} 50 | Array[{{items.type}}] ({{collectionFormat}}){{type}} {{#format}}({{format}}){{/format}}
62 | {{/if}} 63 | 64 | 65 | #### Response 66 | 67 | {{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}} 68 | 69 | 70 | | Status Code | Reason | Response Model | 71 | |-------------|-------------|----------------| 72 | {{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}{{basename schema.$ref}}{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{/ifeq}}{{^schema}} - {{/schema}}| 73 | {{/each}} 74 | -------------------------------------------------------------------------------- /templates/security.hbs: -------------------------------------------------------------------------------- 1 | {{#each securityDefinitions}} 2 | ### {{@key}} 3 | {{#this}} 4 | {{#ifeq type "oauth2"}} 5 | 6 | 7 | 8 | 9 | 10 | {{#if description}} 11 | 12 | 13 | 14 | 15 | {{/if}} 16 | {{#if authorizationUrl}} 17 | 18 | 19 | 20 | 21 | {{/if}} 22 | {{#if flow}} 23 | 24 | 25 | 26 | 27 | {{/if}} 28 | {{#if tokenUrl}} 29 | 30 | 31 | 32 | 33 | {{/if}} 34 | {{#if scopes}} 35 | 36 | 37 | {{#each scopes}} 38 | 39 | 40 | 41 | 42 | {{/each}} 43 | 44 | {{/if}} 45 |
type{{type}}
description{{description}}
authorizationUrl{{authorizationUrl}}
flow{{flow}}
tokenUrl{{tokenUrl}}
scopes{{@key}}{{this}}
46 | {{/ifeq}} 47 | {{#ifeq type "apiKey"}} 48 | 49 | 50 | 51 | 52 | 53 | {{#if description}} 54 | 55 | 56 | 57 | 58 | {{/if}} 59 | {{#if name}} 60 | 61 | 62 | 63 | 64 | {{/if}} 65 | {{#if in}} 66 | 67 | 68 | 69 | 70 | {{/if}} 71 |
type{{type}}
description{{description}}
name{{name}}
in{{in}}
72 | {{/ifeq}} 73 | {{#ifeq type "basic"}} 74 | 75 | 76 | 77 | 78 | 79 | {{#if description}} 80 | 81 | 82 | 83 | 84 | {{/if}} 85 |
type{{type}}
description{{description}}
86 | {{/ifeq}} 87 | {{/this}} 88 | {{/each}} -------------------------------------------------------------------------------- /templates/strapdown.html.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | API Document 4 | 5 | 6 | {{>markdown}} 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------