├── src
├── test
│ ├── resources
│ │ ├── myassets
│ │ │ └── test.html
│ │ ├── test-simple.yaml
│ │ ├── test-simple-with-root-path.yaml
│ │ ├── test-default-with-path-set-programatically.yaml
│ │ ├── test-simple-with-context-path.yaml
│ │ ├── test-simple-with-context-and-root-path.yaml
│ │ ├── test-default.yaml
│ │ ├── test-default-assets.yaml
│ │ ├── test-default-root-path.yaml
│ │ ├── test-default-context-path.yaml
│ │ └── test-default-context-and-root-path.yaml
│ └── java
│ │ └── io
│ │ └── federecio
│ │ └── dropwizard
│ │ └── swagger
│ │ ├── TestConfiguration.java
│ │ ├── TestApplicationWithAssetsAndPathSetProgramatically.java
│ │ ├── DefaultServerTest.java
│ │ ├── SimpleServerTest.java
│ │ ├── DefaultServerWithRootPathSetTest.java
│ │ ├── TestResource.java
│ │ ├── DefaultServerWithApplicationContextPathSetTest.java
│ │ ├── SimpleServerWithRootPathSetTest.java
│ │ ├── SimpleServerWithApplicationContextPathSetTest.java
│ │ ├── selenium
│ │ ├── SimpleServerSeleniumTest.java
│ │ ├── DefaultServerWithRootPathSetSeleniumTest.java
│ │ ├── DefaultServerWithApplicationContextPathSetSeleniumTest.java
│ │ ├── SimpleServerWithRootPathSeleniumTest.java
│ │ ├── DefaultServerSeleniumTest.java
│ │ ├── DefaultServerWithApplicationContextPathAndRootPathSetSeleniumTest.java
│ │ ├── SimpleServerWithApplicationContextPathAndRootPathSeleniumTest.java
│ │ ├── DefaultServerWithPathSetProgramaticallySeleniumTest.java
│ │ ├── SimpleServerWithApplicationContextPathSeleniumTest.java
│ │ ├── DefaultServerWithAssetsSeleniumTest.java
│ │ └── SeleniumTest.java
│ │ ├── DefaultServerWithApplicationContextPathAndRootPathSetTest.java
│ │ ├── SimpleServerWithApplicationContextPathAndRootPathSetTest.java
│ │ ├── DefaultServerWithPathSetProgramaticallyTest.java
│ │ ├── TestApplication.java
│ │ ├── TestApplicationWithPathSetProgramatically.java
│ │ └── DropwizardTest.java
└── main
│ ├── resources
│ ├── swagger-static
│ │ ├── images
│ │ │ ├── throbber.gif
│ │ │ ├── logo_small.png
│ │ │ ├── pet_store_api.png
│ │ │ ├── wordnik_api.png
│ │ │ └── explorer_icons.png
│ │ ├── fonts
│ │ │ ├── droid-sans-v6-latin-700.eot
│ │ │ ├── droid-sans-v6-latin-700.ttf
│ │ │ ├── droid-sans-v6-latin-700.woff
│ │ │ ├── droid-sans-v6-latin-700.woff2
│ │ │ ├── droid-sans-v6-latin-regular.eot
│ │ │ ├── droid-sans-v6-latin-regular.ttf
│ │ │ ├── droid-sans-v6-latin-regular.woff
│ │ │ └── droid-sans-v6-latin-regular.woff2
│ │ ├── lib
│ │ │ ├── jquery.slideto.min.js
│ │ │ ├── jquery.wiggle.min.js
│ │ │ ├── jquery.ba-bbq.min.js
│ │ │ ├── highlight.7.3.pack.js
│ │ │ ├── shred
│ │ │ │ └── content.js
│ │ │ ├── swagger-oauth.js
│ │ │ ├── underscore-min.js
│ │ │ ├── backbone-min.js
│ │ │ └── marked.js
│ │ ├── o2c.html
│ │ ├── css
│ │ │ ├── typography.css
│ │ │ └── reset.css
│ │ └── index.html
│ └── io
│ │ └── federecio
│ │ └── dropwizard
│ │ └── swagger
│ │ └── index.ftl
│ └── java
│ └── io
│ └── federecio
│ └── dropwizard
│ └── swagger
│ ├── SwaggerUIConfiguration.java
│ ├── SwaggerResource.java
│ ├── Constants.java
│ ├── SwaggerView.java
│ ├── ConfigurationHelper.java
│ ├── SwaggerBundleConfiguration.java
│ └── SwaggerBundle.java
├── .gitignore
├── license.txt
├── README.md
└── pom.xml
/src/test/resources/myassets/test.html:
--------------------------------------------------------------------------------
1 |
test asset
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.ipr
3 | *.iws
4 | target/
5 | .idea/
6 | .DS_Store
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/images/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/images/throbber.gif
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/images/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/images/logo_small.png
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/images/pet_store_api.png
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/images/wordnik_api.png
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/images/explorer_icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/images/explorer_icons.png
--------------------------------------------------------------------------------
/src/test/resources/test-simple.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: simple
3 | connector:
4 | type: http
5 | port: 55668
6 | swagger:
7 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.eot
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.ttf
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.woff
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-700.woff2
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.eot
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.ttf
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.woff
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wikia/dropwizard-swagger/master/src/main/resources/swagger-static/fonts/droid-sans-v6-latin-regular.woff2
--------------------------------------------------------------------------------
/src/test/resources/test-simple-with-root-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: simple
3 | rootPath: /api/*
4 | connector:
5 | type: http
6 | port: 51478
7 | swagger:
8 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default-with-path-set-programatically.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | applicationConnectors:
4 | - type: http
5 | port: 33333
6 | adminConnectors:
7 | - type: http
8 | port: 44449
--------------------------------------------------------------------------------
/src/test/resources/test-simple-with-context-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: simple
3 | applicationContextPath: /
4 | connector:
5 | type: http
6 | port: 51378
7 | swagger:
8 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-simple-with-context-and-root-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: simple
3 | applicationContextPath: /
4 | rootPath: /api/*
5 | connector:
6 | type: http
7 | port: 51578
8 | swagger:
9 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | applicationConnectors:
4 | - type: http
5 | port: 44444
6 | adminConnectors:
7 | - type: http
8 | port: 44445
9 | swagger:
10 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default-assets.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | applicationConnectors:
4 | - type: http
5 | port: 33355
6 | adminConnectors:
7 | - type: http
8 | port: 44450
9 | swagger:
10 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default-root-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | rootPath: /api/*
4 | applicationConnectors:
5 | - type: http
6 | port: 41414
7 | adminConnectors:
8 | - type: http
9 | port: 41415
10 | swagger:
11 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default-context-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | applicationContextPath: /app
4 | applicationConnectors:
5 | - type: http
6 | port: 43434
7 | adminConnectors:
8 | - type: http
9 | port: 43435
10 | swagger:
11 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/test/resources/test-default-context-and-root-path.yaml:
--------------------------------------------------------------------------------
1 | server:
2 | type: default
3 | applicationContextPath: /app
4 | rootPath: /api/*
5 | applicationConnectors:
6 | - type: http
7 | port: 42424
8 | adminConnectors:
9 | - type: http
10 | port: 42425
11 | swagger:
12 | resourcePackage: io.federecio.dropwizard.swagger
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/lib/jquery.slideto.min.js:
--------------------------------------------------------------------------------
1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
2 |
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/o2c.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2014 Federico Recio
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/lib/jquery.wiggle.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | jQuery Wiggle
3 | Author: WonderGroup, Jordan Thomas
4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html
5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License)
6 | */
7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/SwaggerUIConfiguration.java:
--------------------------------------------------------------------------------
1 | package io.federecio.dropwizard.swagger;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 |
5 | public class SwaggerUIConfiguration {
6 | @JsonProperty
7 | String authName = "api_key";
8 |
9 | @JsonProperty
10 | String authKey = "api_key";
11 |
12 | @JsonProperty
13 | String authKeyLocation = "query";
14 |
15 | public String getAuthName() {
16 | return authName;
17 | }
18 |
19 | public void setAuthName(String authName) {
20 | this.authName = authName;
21 | }
22 |
23 | public String getAuthKey() {
24 | return authKey;
25 | }
26 |
27 | public void setAuthKey(String authKey) {
28 | this.authKey = authKey;
29 | }
30 |
31 | public String getAuthKeyLocation() {
32 | return authKeyLocation;
33 | }
34 |
35 | public void setAuthKeyLocation(String authKeyLocation) {
36 | this.authKeyLocation = authKeyLocation;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/TestConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import com.fasterxml.jackson.annotation.JsonProperty;
19 | import io.dropwizard.Configuration;
20 |
21 | /**
22 | * @author Federico Recio
23 | */
24 | public class TestConfiguration extends Configuration {
25 |
26 | @JsonProperty("swagger")
27 | public SwaggerBundleConfiguration swaggerBundleConfiguration;
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/TestApplicationWithAssetsAndPathSetProgramatically.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.dropwizard.assets.AssetsBundle;
19 | import io.dropwizard.setup.Bootstrap;
20 |
21 | /**
22 | * @author Federico Recio
23 | */
24 | public class TestApplicationWithAssetsAndPathSetProgramatically extends TestApplicationWithPathSetProgramatically {
25 | @Override
26 | public void initialize(Bootstrap bootstrap) {
27 | super.initialize(bootstrap);
28 | bootstrap.addBundle(new AssetsBundle("/myassets", "/"));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DefaultServerTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default.yaml")
27 | public class DefaultServerTest extends DropwizardTest {
28 |
29 | public DefaultServerTest() {
30 | super(44444, "/");
31 | }
32 | }
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/SimpleServerTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple.yaml")
27 | public class SimpleServerTest extends DropwizardTest {
28 |
29 | public SimpleServerTest() {
30 | super(55668, "/application");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DefaultServerWithRootPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | @RunWith(DropwizardJunitRunner.class)
23 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-root-path.yaml")
24 | public class DefaultServerWithRootPathSetTest extends DropwizardTest {
25 |
26 | public DefaultServerWithRootPathSetTest() {
27 | super(41414, "/api");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/TestResource.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.swagger.annotations.Api;
19 | import io.swagger.annotations.ApiOperation;
20 |
21 | import javax.ws.rs.GET;
22 | import javax.ws.rs.Path;
23 | import javax.ws.rs.core.Response;
24 |
25 | /**
26 | * @author Federico Recio
27 | */
28 | @Path("/test.json")
29 | @Api("/test")
30 | public class TestResource {
31 | public static final String OPERATION_DESCRIPTION = "This is a dummy endpoint for test";
32 |
33 | @GET
34 | @ApiOperation(OPERATION_DESCRIPTION)
35 | public Response dummyEndpoint() {
36 | return Response.ok().build();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DefaultServerWithApplicationContextPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | @RunWith(DropwizardJunitRunner.class)
23 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-context-path.yaml")
24 | public class DefaultServerWithApplicationContextPathSetTest extends DropwizardTest {
25 |
26 | public DefaultServerWithApplicationContextPathSetTest(){
27 | super(43434, "/app");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/SimpleServerWithRootPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-root-path.yaml")
27 | public class SimpleServerWithRootPathSetTest extends DropwizardTest {
28 |
29 | public SimpleServerWithRootPathSetTest() {
30 | super(51478, "/application/api");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/SimpleServerWithApplicationContextPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-context-path.yaml")
27 | public class SimpleServerWithApplicationContextPathSetTest extends DropwizardTest {
28 |
29 | public SimpleServerWithApplicationContextPathSetTest() {
30 | super(51378, "/");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/SimpleServerSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple.yaml")
24 | @RunWith(DropwizardJunitRunner.class)
25 | public class SimpleServerSeleniumTest extends SeleniumTest {
26 |
27 | @Override
28 | protected String getSwaggerUrl() {
29 | return getSwaggerUrl(55668, "/application/swagger");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DefaultServerWithApplicationContextPathAndRootPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | @RunWith(DropwizardJunitRunner.class)
23 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-context-and-root-path.yaml")
24 | public class DefaultServerWithApplicationContextPathAndRootPathSetTest extends DropwizardTest {
25 |
26 | public DefaultServerWithApplicationContextPathAndRootPathSetTest() {
27 | super(42424, "/app/api");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerWithRootPathSetSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | @RunWith(DropwizardJunitRunner.class)
24 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-root-path.yaml")
25 | public class DefaultServerWithRootPathSetSeleniumTest extends SeleniumTest {
26 |
27 | @Override
28 | protected String getSwaggerUrl() {
29 | return getSwaggerUrl(41414, "/api/swagger");
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/SimpleServerWithApplicationContextPathAndRootPathSetTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-context-and-root-path.yaml")
27 | public class SimpleServerWithApplicationContextPathAndRootPathSetTest extends DropwizardTest {
28 |
29 | public SimpleServerWithApplicationContextPathAndRootPathSetTest() {
30 | super(51578, "/api");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/SwaggerResource.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import javax.ws.rs.GET;
19 | import javax.ws.rs.Path;
20 | import javax.ws.rs.Produces;
21 | import javax.ws.rs.core.MediaType;
22 |
23 | /**
24 | * @author Federico Recio
25 | */
26 | @Path(Constants.SWAGGER_PATH)
27 | @Produces(MediaType.TEXT_HTML)
28 | public class SwaggerResource {
29 | private final String urlPattern;
30 | private final SwaggerUIConfiguration config;
31 |
32 | public SwaggerResource(String urlPattern, SwaggerUIConfiguration config) {
33 | this.urlPattern = urlPattern;
34 | this.config = config;
35 | }
36 |
37 | @GET
38 | public SwaggerView get() {
39 | return new SwaggerView(urlPattern, config);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerWithApplicationContextPathSetSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | @RunWith(DropwizardJunitRunner.class)
24 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-context-path.yaml")
25 | public class DefaultServerWithApplicationContextPathSetSeleniumTest extends SeleniumTest {
26 |
27 | @Override
28 | protected String getSwaggerUrl() {
29 | return getSwaggerUrl(43434, "/app/swagger");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DefaultServerWithPathSetProgramaticallyTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import org.junit.runner.RunWith;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | @RunWith(DropwizardJunitRunner.class)
26 | @DropwizardTestConfig(applicationClass = TestApplicationWithPathSetProgramatically.class, yamlFile = "/test-default-with-path-set-programatically.yaml")
27 | public class DefaultServerWithPathSetProgramaticallyTest extends DropwizardTest {
28 |
29 | public DefaultServerWithPathSetProgramaticallyTest() {
30 | super(33333, TestApplicationWithPathSetProgramatically.BASE_PATH);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/SimpleServerWithRootPathSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | /**
24 | * @author Federico Recio
25 | */
26 | @RunWith(DropwizardJunitRunner.class)
27 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-root-path.yaml")
28 | public class SimpleServerWithRootPathSeleniumTest extends SeleniumTest {
29 |
30 | @Override
31 | protected String getSwaggerUrl() {
32 | return getSwaggerUrl(51478, "/application/api/swagger");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.Constants;
21 | import io.federecio.dropwizard.swagger.TestApplication;
22 | import org.junit.runner.RunWith;
23 |
24 | /**
25 | * @author Federico Recio
26 | */
27 | @RunWith(DropwizardJunitRunner.class)
28 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default.yaml")
29 | public class DefaultServerSeleniumTest extends SeleniumTest {
30 |
31 | @Override
32 | protected String getSwaggerUrl() {
33 | return getSwaggerUrl(44444, Constants.SWAGGER_PATH);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerWithApplicationContextPathAndRootPathSetSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | @RunWith(DropwizardJunitRunner.class)
24 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-default-context-and-root-path.yaml")
25 | public class DefaultServerWithApplicationContextPathAndRootPathSetSeleniumTest extends SeleniumTest {
26 |
27 | @Override
28 | protected String getSwaggerUrl() {
29 | return getSwaggerUrl(42424, "/app/api/swagger");
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/SimpleServerWithApplicationContextPathAndRootPathSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplication;
21 | import org.junit.runner.RunWith;
22 |
23 | /**
24 | * @author Federico Recio
25 | */
26 | @RunWith(DropwizardJunitRunner.class)
27 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-context-and-root-path.yaml")
28 | public class SimpleServerWithApplicationContextPathAndRootPathSeleniumTest extends SeleniumTest {
29 |
30 | @Override
31 | protected String getSwaggerUrl() {
32 | return getSwaggerUrl(51578, "/api/swagger");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerWithPathSetProgramaticallySeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.TestApplicationWithPathSetProgramatically;
21 | import org.junit.runner.RunWith;
22 |
23 | /**
24 | * @author Federico Recio
25 | */
26 | @RunWith(DropwizardJunitRunner.class)
27 | @DropwizardTestConfig(applicationClass = TestApplicationWithPathSetProgramatically.class, yamlFile = "/test-default-with-path-set-programatically.yaml")
28 | public class DefaultServerWithPathSetProgramaticallySeleniumTest extends SeleniumTest {
29 |
30 | @Override
31 | protected String getSwaggerUrl() {
32 | return "http://localhost:33333/api/swagger";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/SimpleServerWithApplicationContextPathSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.Constants;
21 | import io.federecio.dropwizard.swagger.TestApplication;
22 | import org.junit.runner.RunWith;
23 |
24 | /**
25 | * @author Federico Recio
26 | */
27 | @RunWith(DropwizardJunitRunner.class)
28 | @DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test-simple-with-context-path.yaml")
29 | public class SimpleServerWithApplicationContextPathSeleniumTest extends SeleniumTest {
30 |
31 | @Override
32 | protected String getSwaggerUrl() {
33 | return getSwaggerUrl(51378, Constants.SWAGGER_PATH);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/css/typography.css:
--------------------------------------------------------------------------------
1 | /* droid-sans-regular - latin */
2 | @font-face {
3 | font-family: 'Droid Sans';
4 | font-style: normal;
5 | font-weight: 400;
6 | src: url('../fonts/droid-sans-v6-latin-regular.eot'); /* IE9 Compat Modes */
7 | src: local('Droid Sans'), local('DroidSans'),
8 | url('../fonts/droid-sans-v6-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
9 | url('../fonts/droid-sans-v6-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
10 | url('../fonts/droid-sans-v6-latin-regular.woff') format('woff'), /* Modern Browsers */
11 | url('../fonts/droid-sans-v6-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
12 | url('../fonts/droid-sans-v6-latin-regular.svg#DroidSans') format('svg'); /* Legacy iOS */
13 | }
14 | /* droid-sans-700 - latin */
15 | @font-face {
16 | font-family: 'Droid Sans';
17 | font-style: normal;
18 | font-weight: 700;
19 | src: url('../fonts/droid-sans-v6-latin-700.eot'); /* IE9 Compat Modes */
20 | src: local('Droid Sans Bold'), local('DroidSans-Bold'),
21 | url('../fonts/droid-sans-v6-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
22 | url('../fonts/droid-sans-v6-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
23 | url('../fonts/droid-sans-v6-latin-700.woff') format('woff'), /* Modern Browsers */
24 | url('../fonts/droid-sans-v6-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
25 | url('../fonts/droid-sans-v6-latin-700.svg#DroidSans') format('svg'); /* Legacy iOS */
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/TestApplication.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.dropwizard.Application;
19 | import io.dropwizard.setup.Bootstrap;
20 | import io.dropwizard.setup.Environment;
21 |
22 | /**
23 | * @author Federico Recio
24 | */
25 | public class TestApplication extends Application {
26 |
27 | @Override
28 | public void initialize(Bootstrap bootstrap) {
29 | bootstrap.addBundle(new SwaggerBundle() {
30 | @Override
31 | protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(TestConfiguration configuration) {
32 | return configuration.swaggerBundleConfiguration;
33 | }
34 | });
35 | }
36 |
37 | @Override
38 | public void run(TestConfiguration configuration, Environment environment) throws Exception {
39 | environment.jersey().register(new TestResource());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/css/reset.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
2 | html,
3 | body,
4 | div,
5 | span,
6 | applet,
7 | object,
8 | iframe,
9 | h1,
10 | h2,
11 | h3,
12 | h4,
13 | h5,
14 | h6,
15 | p,
16 | blockquote,
17 | pre,
18 | a,
19 | abbr,
20 | acronym,
21 | address,
22 | big,
23 | cite,
24 | code,
25 | del,
26 | dfn,
27 | em,
28 | img,
29 | ins,
30 | kbd,
31 | q,
32 | s,
33 | samp,
34 | small,
35 | strike,
36 | strong,
37 | sub,
38 | sup,
39 | tt,
40 | var,
41 | b,
42 | u,
43 | i,
44 | center,
45 | dl,
46 | dt,
47 | dd,
48 | ol,
49 | ul,
50 | li,
51 | fieldset,
52 | form,
53 | label,
54 | legend,
55 | table,
56 | caption,
57 | tbody,
58 | tfoot,
59 | thead,
60 | tr,
61 | th,
62 | td,
63 | article,
64 | aside,
65 | canvas,
66 | details,
67 | embed,
68 | figure,
69 | figcaption,
70 | footer,
71 | header,
72 | hgroup,
73 | menu,
74 | nav,
75 | output,
76 | ruby,
77 | section,
78 | summary,
79 | time,
80 | mark,
81 | audio,
82 | video {
83 | margin: 0;
84 | padding: 0;
85 | border: 0;
86 | font-size: 100%;
87 | font: inherit;
88 | vertical-align: baseline;
89 | }
90 | /* HTML5 display-role reset for older browsers */
91 | article,
92 | aside,
93 | details,
94 | figcaption,
95 | figure,
96 | footer,
97 | header,
98 | hgroup,
99 | menu,
100 | nav,
101 | section {
102 | display: block;
103 | }
104 | body {
105 | line-height: 1;
106 | }
107 | ol,
108 | ul {
109 | list-style: none;
110 | }
111 | blockquote,
112 | q {
113 | quotes: none;
114 | }
115 | blockquote:before,
116 | blockquote:after,
117 | q:before,
118 | q:after {
119 | content: '';
120 | content: none;
121 | }
122 | table {
123 | border-collapse: collapse;
124 | border-spacing: 0;
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | /**
19 | * @author Federico Recio
20 | */
21 | public class Constants {
22 | /**
23 | * The project's directory in which Swagger static assets live
24 | */
25 | public static final String SWAGGER_RESOURCES_PATH = "/swagger-static";
26 | /**
27 | * The path with which all HTTP requests for Swagger assets should be prefixed.
28 | */
29 | public static final String SWAGGER_URI_PATH = SWAGGER_RESOURCES_PATH;
30 | /**
31 | * The name of the {@link io.dropwizard.assets.AssetsBundle} to register.
32 | */
33 | public static final String SWAGGER_ASSETS_NAME = "swagger-assets";
34 | /**
35 | * Default host name will be used if the host cannot be determined by other means.
36 | */
37 | public static final String DEFAULT_SWAGGER_HOST = "localhost";
38 | /**
39 | * The URL to use to determine this host's name when running in AWS.
40 | */
41 | public static final String AWS_HOST_NAME_URL = "http://169.254.169.254/latest/meta-data/public-hostname/";
42 | /**
43 | * The file to check for its existence to determine if the server is running on AWS.
44 | */
45 | public static final String AWS_FILE_TO_CHECK = "/var/lib/cloud/";
46 | /**
47 | * The path to which Swagger resources are bound to
48 | */
49 | public static final String SWAGGER_PATH = "/swagger";
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/DefaultServerWithAssetsSeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.junitrunner.DropwizardJunitRunner;
19 | import io.federecio.dropwizard.junitrunner.DropwizardTestConfig;
20 | import io.federecio.dropwizard.swagger.Constants;
21 | import io.federecio.dropwizard.swagger.TestApplicationWithAssetsAndPathSetProgramatically;
22 | import io.federecio.dropwizard.swagger.TestApplicationWithPathSetProgramatically;
23 | import org.junit.Test;
24 | import org.junit.runner.RunWith;
25 | import org.openqa.selenium.By;
26 | import org.openqa.selenium.support.ui.ExpectedConditions;
27 | import org.openqa.selenium.support.ui.WebDriverWait;
28 |
29 | import java.util.concurrent.TimeUnit;
30 |
31 | /**
32 | * @author Federico Recio
33 | */
34 | @RunWith(DropwizardJunitRunner.class)
35 | @DropwizardTestConfig(applicationClass = TestApplicationWithAssetsAndPathSetProgramatically.class, yamlFile = "/test-default-assets.yaml")
36 | public class DefaultServerWithAssetsSeleniumTest extends SeleniumTest {
37 |
38 | public static final String BASE_URL = "http://localhost:33355";
39 | private static final String BASE_URL_WITH_BASE_PATH = BASE_URL + TestApplicationWithPathSetProgramatically.BASE_PATH;
40 |
41 | @Override
42 | protected String getSwaggerUrl() {
43 | return BASE_URL_WITH_BASE_PATH + Constants.SWAGGER_PATH;
44 | }
45 |
46 | @Test
47 | public void testApplicationAssetsAreAccessible() throws Exception {
48 | driver.get(BASE_URL + "/test.html");
49 | driver.manage().timeouts().implicitlyWait(WAIT_IN_SECONDS, TimeUnit.SECONDS);
50 |
51 | By xpath = By.xpath("//h1");
52 | new WebDriverWait(driver, WAIT_IN_SECONDS).until(ExpectedConditions.textToBePresentInElementLocated(xpath, "test asset"));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/TestApplicationWithPathSetProgramatically.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.dropwizard.Application;
19 | import io.dropwizard.server.DefaultServerFactory;
20 | import io.dropwizard.setup.Bootstrap;
21 | import io.dropwizard.setup.Environment;
22 |
23 | /**
24 | * @author Federico Recio
25 | */
26 | public class TestApplicationWithPathSetProgramatically extends Application {
27 |
28 | public static final String BASE_PATH = "/api";
29 |
30 | @Override
31 | public void initialize(Bootstrap bootstrap) {
32 | bootstrap.addBundle(new SwaggerBundle() {
33 | @Override
34 | protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(TestConfiguration configuration) {
35 | SwaggerBundleConfiguration swaggerBundleConfiguration = new SwaggerBundleConfiguration();
36 | swaggerBundleConfiguration.setResourcePackage("io.federecio.dropwizard.swagger");
37 |
38 | // since this Application sets the root path in the run() method, we need to
39 | // tell the bundle what that path is because by the time the bundle initializes
40 | // it will not have the necessary info to derive the path that is later going to
41 | // be set below in the run() method.
42 | swaggerBundleConfiguration.setUriPrefix(BASE_PATH);
43 | return swaggerBundleConfiguration;
44 | }
45 | });
46 | }
47 |
48 | @Override
49 | public void run(TestConfiguration configuration, final Environment environment) throws Exception {
50 | ((DefaultServerFactory) configuration.getServerFactory()).setJerseyRootPath(BASE_PATH + "/*");
51 | environment.jersey().register(new TestResource());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/SwaggerView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import com.google.common.base.Charsets;
19 | import io.dropwizard.views.View;
20 |
21 | /**
22 | * Serves the content of Swagger's index page which has been "templatized" to support replacing
23 | * the directory in which Swagger's static content is located (i.e. JS files) and the path with
24 | * which requests to resources need to be prefixed
25 | *
26 | * @author Federico Recio
27 | */
28 | public class SwaggerView extends View {
29 |
30 | private final String swaggerAssetsPath;
31 | private final String contextPath;
32 | private final SwaggerUIConfiguration config;
33 |
34 | protected SwaggerView(String urlPattern, SwaggerUIConfiguration config) {
35 | super("index.ftl", Charsets.UTF_8);
36 | this.config = config;
37 |
38 | if (urlPattern.equals("/")) {
39 | swaggerAssetsPath = Constants.SWAGGER_URI_PATH;
40 | } else {
41 | swaggerAssetsPath = urlPattern + Constants.SWAGGER_URI_PATH;
42 | }
43 |
44 | if (urlPattern.equals("/")) {
45 | contextPath = "";
46 | } else {
47 | contextPath = urlPattern;
48 | }
49 | }
50 |
51 | /**
52 | * Returns the path with which all requests for Swagger's static content need to be prefixed
53 | */
54 | @SuppressWarnings("unused")
55 | public String getSwaggerAssetsPath() {
56 | return swaggerAssetsPath;
57 | }
58 |
59 | /**
60 | * Returns the path with with which all requests made by Swagger's UI to Resources need to be prefixed
61 | */
62 | @SuppressWarnings("unused")
63 | public String getContextPath() {
64 | return contextPath;
65 | }
66 |
67 | @SuppressWarnings("unused")
68 | public String getAuthName() {
69 | return config.getAuthName();
70 | }
71 |
72 | @SuppressWarnings("unused")
73 | public String getAuthKey() {
74 | return config.getAuthKey();
75 | }
76 |
77 | @SuppressWarnings("unused")
78 | public String getAuthKeyLocation() {
79 | return config.getAuthKeyLocation();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/selenium/SeleniumTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger.selenium;
17 |
18 | import io.federecio.dropwizard.swagger.Constants;
19 | import org.junit.After;
20 | import org.junit.Before;
21 | import org.junit.Test;
22 | import org.openqa.selenium.By;
23 | import org.openqa.selenium.firefox.FirefoxDriver;
24 | import org.openqa.selenium.support.ui.ExpectedConditions;
25 | import org.openqa.selenium.support.ui.WebDriverWait;
26 |
27 | import java.net.InetAddress;
28 | import java.net.UnknownHostException;
29 | import java.util.concurrent.TimeUnit;
30 |
31 | public abstract class SeleniumTest {
32 |
33 | static final String host;
34 |
35 | static {
36 | String tmpHost;
37 |
38 | try {
39 | tmpHost = InetAddress.getLocalHost().getHostName();
40 | } catch (UnknownHostException ignored) {
41 | tmpHost = Constants.DEFAULT_SWAGGER_HOST;
42 | }
43 |
44 | host = tmpHost;
45 | }
46 |
47 | static final int WAIT_IN_SECONDS = 5;
48 | FirefoxDriver driver;
49 |
50 | protected String getSwaggerUrl(int port, String path) {
51 | return String.format("http://%s:%d%s", SeleniumTest.host, port, path);
52 | }
53 |
54 | protected abstract String getSwaggerUrl();
55 |
56 | @Before
57 | public void setUpTests() {
58 | driver = new FirefoxDriver();
59 | }
60 |
61 | @After
62 | public void terminate() {
63 | if (driver != null) {
64 | driver.kill();
65 | }
66 | }
67 |
68 | @Test
69 | public void testResourceIsAccessibleThroughUI() throws Exception {
70 | driver.get(getSwaggerUrl() + "#!/test/dummyEndpoint");
71 | driver.manage().timeouts().implicitlyWait(WAIT_IN_SECONDS, TimeUnit.SECONDS);
72 |
73 | clickOnTryOut();
74 | assertResponseCodeIs200();
75 | }
76 |
77 | private void assertResponseCodeIs200() {
78 | By xpath = By.xpath("//div[@class='block response_code']/pre");
79 | new WebDriverWait(driver, WAIT_IN_SECONDS).until(ExpectedConditions.textToBePresentInElementLocated(xpath, "200"));
80 | }
81 |
82 | private void clickOnTryOut() {
83 | By xpath = By.xpath("//input[@value='Try it out!']");
84 | new WebDriverWait(driver, WAIT_IN_SECONDS).until(ExpectedConditions.presenceOfElementLocated(xpath));
85 | driver.findElement(xpath).click();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/test/java/io/federecio/dropwizard/swagger/DropwizardTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import com.google.common.base.Joiner;
19 | import com.google.common.base.Splitter;
20 | import com.jayway.restassured.RestAssured;
21 | import org.eclipse.jetty.http.HttpStatus;
22 | import org.hamcrest.core.StringContains;
23 | import org.junit.Before;
24 | import org.junit.Test;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | /**
30 | * @author Federico Recio
31 | */
32 | public abstract class DropwizardTest {
33 |
34 | private final int port;
35 | private final Path basePath;
36 |
37 | protected DropwizardTest(int port, String basePath) {
38 | this.port = port;
39 | this.basePath = Path.from(basePath);
40 | }
41 |
42 | @Before
43 | public void setPort() {
44 | RestAssured.port = port;
45 | }
46 |
47 | @Test
48 | public void resourceIsAvailable() throws Exception {
49 | RestAssured.expect().statusCode(HttpStatus.OK_200).when().get(Path.from(basePath, "test.json"));
50 | }
51 |
52 | @Test
53 | public void swaggerIsAvailable() throws Exception {
54 | RestAssured.expect().statusCode(HttpStatus.OK_200).body(StringContains.containsString(TestResource.OPERATION_DESCRIPTION)).when().get(Path.from(basePath, "swagger.json"));
55 | RestAssured.expect().statusCode(HttpStatus.OK_200).when().get(Path.from(basePath, "swagger"));
56 | RestAssured.expect().statusCode(HttpStatus.OK_200).when().get(Path.from(basePath, "swagger") + "/");
57 | }
58 |
59 | static class Path {
60 | private final List pathComponents = new ArrayList<>();
61 |
62 | public static Path from(String basePath) {
63 | Path path = new Path();
64 | path.pathComponents.addAll(Splitter.on("/").omitEmptyStrings().splitToList(basePath));
65 | return path;
66 | }
67 |
68 | public static String from(Path basePath, String additionalPath) {
69 | List pathComponents = new ArrayList<>();
70 | pathComponents.addAll(basePath.pathComponents);
71 | pathComponents.add(additionalPath);
72 | return asString(pathComponents);
73 | }
74 |
75 | public static String asString(List pathComponents) {
76 | return pathComponents.isEmpty() ? "/" : Joiner.on("/").join(pathComponents);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | dropwizard-swagger
2 | ==================
3 |
4 | a Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints. Swagger UI static content is taken from https://github.com/swagger-api/swagger-ui
5 |
6 | Current version has been tested with Dropwizard 0.8.0 and Swagger 1.5.4 which supports Swagger 2 spec!
7 |
8 | Note: if you come from previous versions there have been some changes in the way the bundle is configured, see details below.
9 |
10 | License
11 | -------
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Version matrix
16 | --------------
17 |
18 | dropwizard-swagger|Dropwizard|Swagger API|Swagger UI
19 | ------------------|----------|-----------|----------
20 | < 0.5 | 0.7.x | 1.3.2 | ?
21 | 0.5.x | 0.7.x | 1.3.12 | v2.1.4-M1
22 | 0.6.x | 0.8.0 | 1.3.12 | v2.1.4-M1
23 | 0.7.x | 0.8.0 | 1.5.1-M2| v2.1.4-M1
24 | 0.8.x | 0.8.4 | 1.5.4 | v2.1.4-M1
25 |
26 | How to use it
27 | -------------
28 |
29 | * Add the Maven dependency (available in Maven Central)
30 |
31 |
32 | io.federecio
33 | dropwizard-swagger
34 | 0.7.0
35 |
36 |
37 |
38 | * Add the following to your Configuration class:
39 |
40 | public class YourConfiguration extends Configuration {
41 | ...
42 | @JsonProperty("swagger")
43 | public SwaggerBundleConfiguration swaggerBundleConfiguration;
44 |
45 | * Add the following your configuration yaml (this is the minimal configuration you need):
46 |
47 | prop1: value1
48 | prop2: value2
49 | ...
50 | # the only required property is resourcePackage, for more config options see below
51 | swagger:
52 | resourcePackage:
53 |
54 |
55 |
56 | * In your Application class:
57 |
58 | @Override
59 | public void initialize(Bootstrap bootstrap) {
60 | ...
61 | bootstrap.addBundle(new SwaggerBundle() {
62 | @Override
63 | protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(YourConfiguration configuration) {
64 | return configuration.swaggerBundleConfiguration;
65 | }
66 | });
67 | ...
68 | }
69 |
70 |
71 | * As usual, add Swagger annotations to your resource classes and methods
72 |
73 |
74 | * Open a browser and hit `http://localhost:/swagger`
75 |
76 | Sample Application
77 | ------------------
78 |
79 | Take a look at this sample application that shows how to integrate DropWizard and Swagger: [dropwizard-swagger-sample-app](https://github.com/federecio/dropwizard-swagger-sample-app)
80 |
81 | Additional Swagger configuration
82 | --------------------------------
83 |
84 | To see all the properties that can be used to customize Swagger see [SwaggerBundleConfiguration.java](src/main/java/io/federecio/dropwizard/swagger/SwaggerBundleConfiguration.java)
85 |
86 | A note on Swagger 2
87 | -------------------
88 |
89 | Host and port do not seem to be needed for Swagger 2 to work properly as it uses relative URLs. At the moment I haven't run through all the scenarios so some adjustments might be needed, please open a bug if you encounter any problems.
90 |
91 |
92 | Contributors
93 | ------------
94 |
95 | * Federico Recio [@federecio](http://twitter.com/federecio)
96 | * Jochen Szostek [prefabsoft] (http://prefabsoft.com)
97 | * Damien Raude-Morvan [drazzib] (https://github.com/drazzib)
98 | * Marcel Stör [marcelstoer] (https://github.com/marcelstoer)
99 | * Flemming Frandsen https://github.com/dren-dk
100 | * Tristan Burch [tburch] (https://github.com/tburch)
101 | * Matt Carrier [mattcarrier] (https://github.com/mattcarrier)
102 |
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/lib/jquery.ba-bbq.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
3 | * http://benalman.com/projects/jquery-bbq-plugin/
4 | *
5 | * Copyright (c) 2010 "Cowboy" Ben Alman
6 | * Dual licensed under the MIT and GPL licenses.
7 | * http://benalman.com/about/license/
8 | */
9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Swagger UI
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
81 |
82 |
83 |
84 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/src/main/resources/io/federecio/dropwizard/swagger/index.ftl:
--------------------------------------------------------------------------------
1 | <#-- @ftlvariable name="" type="com.federecio.dropwizard.swagger.SwaggerView" -->
2 |
3 |
4 |
5 | Swagger UI
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
76 |
77 |
78 |
79 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/ConfigurationHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import io.dropwizard.Configuration;
19 | import io.dropwizard.server.DefaultServerFactory;
20 | import io.dropwizard.server.ServerFactory;
21 | import io.dropwizard.server.SimpleServerFactory;
22 |
23 | /**
24 | * Wrapper around Dropwizard's configuration and the bundle's config that simplifies getting some
25 | * information from them.
26 | *
27 | * @author Federico Recio
28 | * @author Flemming Frandsen
29 | */
30 | public class ConfigurationHelper {
31 |
32 | private final Configuration configuration;
33 | private final SwaggerBundleConfiguration swaggerBundleConfiguration;
34 |
35 | public ConfigurationHelper(Configuration configuration, SwaggerBundleConfiguration swaggerBundleConfiguration) {
36 | this.configuration = configuration;
37 | this.swaggerBundleConfiguration = swaggerBundleConfiguration;
38 | }
39 |
40 | public String getJerseyRootPath() {
41 | // if the user explictly defined a path to prefix requests use it instead of derive it
42 | if (swaggerBundleConfiguration.getUriPrefix() != null) {
43 | return swaggerBundleConfiguration.getUriPrefix();
44 | }
45 |
46 | String rootPath;
47 |
48 | ServerFactory serverFactory = configuration.getServerFactory();
49 |
50 | if (serverFactory instanceof SimpleServerFactory) {
51 | rootPath = ((SimpleServerFactory) serverFactory).getJerseyRootPath();
52 | } else {
53 | rootPath = ((DefaultServerFactory) serverFactory).getJerseyRootPath();
54 | }
55 |
56 | return stripUrlSlashes(rootPath);
57 | }
58 |
59 | public String getUrlPattern() {
60 | // if the user explictly defined a path to prefix requests use it instead of derive it
61 | if (swaggerBundleConfiguration.getUriPrefix() != null) {
62 | return swaggerBundleConfiguration.getUriPrefix();
63 | }
64 |
65 | final String applicationContextPath = getApplicationContextPath();
66 | final String rootPath = getJerseyRootPath();
67 |
68 | String urlPattern;
69 |
70 | if (rootPath.equals("/") && applicationContextPath.equals("/")) {
71 | urlPattern = "/";
72 | } else if (rootPath.equals("/") && !applicationContextPath.equals("/")) {
73 | urlPattern = applicationContextPath;
74 | } else if (!rootPath.equals("/") && applicationContextPath.equals("/")) {
75 | urlPattern = rootPath;
76 | } else {
77 | urlPattern = applicationContextPath + rootPath;
78 | }
79 |
80 | return urlPattern;
81 | }
82 |
83 | public String getSwaggerUriPath() {
84 | final String jerseyRootPath = getJerseyRootPath();
85 | String uriPathPrefix = jerseyRootPath.equals("/") ? "" : jerseyRootPath;
86 | return uriPathPrefix + Constants.SWAGGER_URI_PATH;
87 | }
88 |
89 | private String getApplicationContextPath() {
90 | String applicationContextPath;
91 |
92 | ServerFactory serverFactory = configuration.getServerFactory();
93 |
94 | if (serverFactory instanceof SimpleServerFactory) {
95 | applicationContextPath = ((SimpleServerFactory) serverFactory).getApplicationContextPath();
96 | } else {
97 | applicationContextPath = ((DefaultServerFactory) serverFactory).getApplicationContextPath();
98 | }
99 |
100 | return stripUrlSlashes(applicationContextPath);
101 | }
102 |
103 | private String stripUrlSlashes(String urlToStrip) {
104 | if (urlToStrip.endsWith("/*")) {
105 | urlToStrip = urlToStrip.substring(0, urlToStrip.length() - 1);
106 | }
107 |
108 | if (urlToStrip.length() > 1 && urlToStrip.endsWith("/")) {
109 | urlToStrip = urlToStrip.substring(0, urlToStrip.length() - 1);
110 | }
111 |
112 | return urlToStrip;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/SwaggerBundleConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 |
21 | /**
22 | * For the meaning of all these properties please refer to Swagger documentation or {@link io.swagger.jaxrs.config.BeanConfig}
23 | *
24 | * @author Tristan Burch
25 | * @author Federico Recio
26 | */
27 | @JsonIgnoreProperties(ignoreUnknown = true)
28 | public class SwaggerBundleConfiguration {
29 |
30 | /**
31 | * This is the only property that is required for Swagger to work correctly.
32 | *
33 | * It is a comma separated list of the all the packages that contain the {@link io.swagger.annotations.Api}
34 | * annoted resources
35 | */
36 | @JsonProperty
37 | private String resourcePackage;
38 |
39 | @JsonProperty
40 | private String title;
41 |
42 | @JsonProperty
43 | private String version;
44 |
45 | @JsonProperty
46 | private String description;
47 |
48 | @JsonProperty
49 | private String termsOfServiceUrl;
50 |
51 | @JsonProperty
52 | private String contact;
53 |
54 | @JsonProperty
55 | private String license;
56 |
57 | @JsonProperty
58 | private String licenseUrl;
59 |
60 | /**
61 | * For most of the scenarios this property is not needed.
62 | *
63 | * This is not a property for Swagger but for bundle to set up Swagger UI correctly.
64 | * It only needs to be used of the root path or the context path is set programatically
65 | * and therefore cannot be derived correctly. The problem arises in that if you set the
66 | * root path or context path in the run() method in your Application subclass the bundle
67 | * has already been initialized by that time and so does not know you set the path programatically.
68 | */
69 | @JsonProperty
70 | private String uriPrefix;
71 |
72 | @JsonProperty("ui")
73 | private SwaggerUIConfiguration uiConfiguration = new SwaggerUIConfiguration();
74 |
75 | public String getResourcePackage() {
76 | return resourcePackage;
77 | }
78 |
79 | public void setResourcePackage(String resourcePackage) {
80 | this.resourcePackage = resourcePackage;
81 | }
82 |
83 | public String getTitle() {
84 | return title;
85 | }
86 |
87 | public void setTitle(String title) {
88 | this.title = title;
89 | }
90 |
91 | public String getVersion() {
92 | return version;
93 | }
94 |
95 | public void setVersion(String version) {
96 | this.version = version;
97 | }
98 |
99 | public String getDescription() {
100 | return description;
101 | }
102 |
103 | public void setDescription(String description) {
104 | this.description = description;
105 | }
106 |
107 | public String getTermsOfServiceUrl() {
108 | return termsOfServiceUrl;
109 | }
110 |
111 | public void setTermsOfServiceUrl(String termsOfServiceUrl) {
112 | this.termsOfServiceUrl = termsOfServiceUrl;
113 | }
114 |
115 | public String getContact() {
116 | return contact;
117 | }
118 |
119 | public void setContact(String contact) {
120 | this.contact = contact;
121 | }
122 |
123 | public String getLicense() {
124 | return license;
125 | }
126 |
127 | public void setLicense(String license) {
128 | this.license = license;
129 | }
130 |
131 | public String getLicenseUrl() {
132 | return licenseUrl;
133 | }
134 |
135 | public void setLicenseUrl(String licenseUrl) {
136 | this.licenseUrl = licenseUrl;
137 | }
138 |
139 | public String getUriPrefix() {
140 | return uriPrefix;
141 | }
142 |
143 | public void setUriPrefix(String uriPrefix) {
144 | this.uriPrefix = uriPrefix;
145 | }
146 |
147 | @JsonProperty("ui")
148 | public SwaggerUIConfiguration getUiConfiguration() {
149 | return uiConfiguration;
150 | }
151 |
152 | @JsonProperty("ui")
153 | public void setUiConfiguration(SwaggerUIConfiguration ui) {
154 | this.uiConfiguration = ui;
155 | }
156 |
157 | @Override
158 | public String toString() {
159 | return "SwaggerBundleConfiguration{" +
160 | "resourcePackage='" + resourcePackage + '\'' +
161 | ", title='" + title + '\'' +
162 | ", version='" + version + '\'' +
163 | ", description='" + description + '\'' +
164 | ", termsOfServiceUrl='" + termsOfServiceUrl + '\'' +
165 | ", contact='" + contact + '\'' +
166 | ", license='" + license + '\'' +
167 | ", licenseUrl='" + licenseUrl + '\'' +
168 | '}';
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/main/java/io/federecio/dropwizard/swagger/SwaggerBundle.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 Federico Recio
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 | package io.federecio.dropwizard.swagger;
17 |
18 | import com.fasterxml.jackson.annotation.JsonInclude;
19 | import io.dropwizard.Configuration;
20 | import io.dropwizard.ConfiguredBundle;
21 | import io.dropwizard.assets.AssetsBundle;
22 | import io.dropwizard.setup.Bootstrap;
23 | import io.dropwizard.setup.Environment;
24 | import io.dropwizard.views.ViewBundle;
25 | import io.swagger.jaxrs.config.BeanConfig;
26 | import io.swagger.jaxrs.listing.ApiListingResource;
27 | import io.swagger.models.Swagger;
28 | import org.eclipse.jetty.servlets.CrossOriginFilter;
29 |
30 | import java.util.EnumSet;
31 |
32 | import javax.servlet.DispatcherType;
33 | import javax.servlet.FilterRegistration;
34 |
35 | /**
36 | * A {@link io.dropwizard.ConfiguredBundle} that provides hassle-free configuration of Swagger and Swagger UI
37 | * on top of Dropwizard.
38 | *
39 | * @author Federico Recio
40 | * @author Flemming Frandsen
41 | * @author Tristan Burch
42 | */
43 | public abstract class SwaggerBundle implements ConfiguredBundle {
44 |
45 | @Override
46 | public void initialize(Bootstrap> bootstrap) {
47 | bootstrap.addBundle(new ViewBundle<>());
48 | }
49 |
50 | @Override
51 | public void run(T configuration, Environment environment) throws Exception {
52 | SwaggerBundleConfiguration swaggerBundleConfiguration = getSwaggerBundleConfiguration(configuration);
53 | if (swaggerBundleConfiguration == null) {
54 | throw new IllegalStateException("You need to provide an instance of SwaggerBundleConfiguration");
55 | }
56 |
57 | ConfigurationHelper configurationHelper = new ConfigurationHelper(configuration, swaggerBundleConfiguration);
58 | new AssetsBundle(Constants.SWAGGER_RESOURCES_PATH, configurationHelper.getSwaggerUriPath(), null, Constants.SWAGGER_ASSETS_NAME).run(environment);
59 |
60 | environment.jersey().register(
61 | new SwaggerResource(
62 | configurationHelper.getUrlPattern(),
63 | swaggerBundleConfiguration.getUiConfiguration()));
64 | environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
65 |
66 | BeanConfig beanConfig = setUpSwagger(swaggerBundleConfiguration,
67 | configurationHelper.getUrlPattern());
68 |
69 | configureCors(environment, "/swagger.json", "/swagger.yaml");
70 |
71 | environment.getApplicationContext().setAttribute("swagger", beanConfig.getSwagger());
72 | environment.jersey().register(new ApiListingResource());
73 | }
74 |
75 | @SuppressWarnings("unused")
76 | protected abstract SwaggerBundleConfiguration getSwaggerBundleConfiguration(T configuration);
77 |
78 | @SuppressWarnings("unused")
79 | protected void setUpSwagger(Swagger swagger) {}
80 |
81 | protected void configureCors(Environment environment, String... urlPatterns) {
82 | FilterRegistration.Dynamic
83 | filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
84 | filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, urlPatterns);
85 | filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
86 | filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
87 | filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
88 | filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
89 | filter.setInitParameter("allowCredentials", "true");
90 | }
91 |
92 | private BeanConfig setUpSwagger(SwaggerBundleConfiguration swaggerBundleConfiguration,
93 | String urlPattern) {
94 | BeanConfig config = new BeanConfig();
95 |
96 | if (swaggerBundleConfiguration.getTitle() != null) {
97 | config.setTitle(swaggerBundleConfiguration.getTitle());
98 | }
99 |
100 | if (swaggerBundleConfiguration.getVersion() != null) {
101 | config.setVersion(swaggerBundleConfiguration.getVersion());
102 | }
103 |
104 | if (swaggerBundleConfiguration.getDescription() != null) {
105 | config.setDescription(swaggerBundleConfiguration.getDescription());
106 | }
107 |
108 | if (swaggerBundleConfiguration.getContact() != null) {
109 | config.setContact(swaggerBundleConfiguration.getContact());
110 | }
111 |
112 | if (swaggerBundleConfiguration.getLicense() != null) {
113 | config.setLicense(swaggerBundleConfiguration.getLicense());
114 | }
115 |
116 | if (swaggerBundleConfiguration.getLicenseUrl() != null) {
117 | config.setLicenseUrl(swaggerBundleConfiguration.getLicenseUrl());
118 | }
119 |
120 | if (swaggerBundleConfiguration.getTermsOfServiceUrl() != null) {
121 | config.setTermsOfServiceUrl(swaggerBundleConfiguration.getTermsOfServiceUrl());
122 | }
123 |
124 | config.setBasePath(urlPattern);
125 |
126 | if (swaggerBundleConfiguration.getResourcePackage() != null) {
127 | config.setResourcePackage(swaggerBundleConfiguration.getResourcePackage());
128 | } else {
129 | throw new IllegalStateException("Resource package needs to be specified for Swagger to correctly detect annotated resources");
130 | }
131 |
132 |
133 | config.setScan(true);
134 | setUpSwagger(config.getSwagger());
135 |
136 | return config;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/main/resources/swagger-static/lib/highlight.7.3.pack.js:
--------------------------------------------------------------------------------
1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=(""+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q'+L[0]+""}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return''+r.value+""}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+=""}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"
")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",rE:true,sL:"css"}},{cN:"tag",b:"