4 | Grails Runtime Exception
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-grails2/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-grails2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #Grails Metadata file
2 | #Thu Aug 01 08:46:22 PDT 2013
3 | app.grails.version=2.2.4
4 | app.name=java-grails2
5 | app.version=0.1
6 | plugins.jaxrs=0.8
7 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/WEB-INF/sitemesh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.eot
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.ttf
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.woff
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-700.woff2
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.eot
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.ttf
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.woff
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/fonts/droid-sans-v6-latin-regular.woff2
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/images/explorer_icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/images/explorer_icons.png
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/images/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/images/logo_small.png
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/images/pet_store_api.png
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/images/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/images/throbber.gif
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/src/main/web-app/images/wordnik_api.png
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/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 |
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/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();}});}});};
--------------------------------------------------------------------------------
/java/java-grails2/src/main/web-app/o2c.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/java/java-grails2/wrapper/grails-wrapper-runtime-2.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/wrapper/grails-wrapper-runtime-2.2.1.jar
--------------------------------------------------------------------------------
/java/java-grails2/wrapper/grails-wrapper.properties:
--------------------------------------------------------------------------------
1 | wrapper.dist.url=http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/
2 |
--------------------------------------------------------------------------------
/java/java-grails2/wrapper/springloaded-core-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-grails2/wrapper/springloaded-core-1.1.1.jar
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} %-5level [%thread] %logger#%method:%line - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/java/java-jaxrs-cxf/src/test/scala/ResourceListingIT.scala:
--------------------------------------------------------------------------------
1 | import io.swagger.models._
2 |
3 | import io.swagger.util.Json
4 |
5 | import org.junit.runner.RunWith
6 |
7 | import org.scalatest.junit.JUnitRunner
8 | import org.scalatest.FlatSpec
9 | import org.scalatest.Matchers
10 |
11 | import java.net.URL
12 |
13 | import scala.collection.JavaConversions._
14 |
15 | @RunWith(classOf[JUnitRunner])
16 | class ResourceListingIT extends FlatSpec with Matchers {
17 | it should "read a resource listing" in {
18 | val swagger = Json.mapper().readValue(new URL("http://localhost:8002/api/swagger.json"), classOf[Swagger])
19 |
20 | swagger.getHost() should be ("localhost:8002")
21 | swagger.getBasePath() should be ("/api")
22 |
23 | val info = swagger.getInfo()
24 |
25 | info should not be (null)
26 | info.getVersion() should be ("1.0.0")
27 | info.getTitle() should be ("Swagger Petstore")
28 | info.getContact() should not be (null)
29 | info.getContact().getName() should be ("apiteam@swagger.io")
30 | info.getLicense() should not be (null)
31 | info.getLicense().getName() should be ("Apache 2.0")
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-annotations/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private static final long serialVersionUID = 1L;
21 | private int code;
22 | public ApiException (int code, String msg) {
23 | super(msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-annotations/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private static final long serialVersionUID = 1L;
21 | private int code;
22 | public BadRequestException (int code, String msg) {
23 | super(code, msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-annotations/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private static final long serialVersionUID = 1L;
21 | private int code;
22 | public NotFoundException (int code, String msg) {
23 | super(code, msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-annotations/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/logs/wordnik.log:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-jaxrs-no-webxml/logs/wordnik.log
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jaxrs-no-webxml/src/test/scala/ResourceListingIT.scala:
--------------------------------------------------------------------------------
1 | import io.swagger.models._
2 |
3 | import io.swagger.util.Json
4 |
5 | import org.junit.runner.RunWith
6 |
7 | import org.scalatest.junit.JUnitRunner
8 | import org.scalatest.FlatSpec
9 | import org.scalatest.Matchers
10 |
11 | import java.net.URL
12 |
13 | import scala.collection.JavaConversions._
14 |
15 | @RunWith(classOf[JUnitRunner])
16 | class ResourceListingIT extends FlatSpec with Matchers {
17 | it should "read a resource listing" in {
18 | val swagger = Json.mapper().readValue(new URL("http://localhost:8002/api/swagger.json"), classOf[Swagger])
19 |
20 | swagger.getHost() should be ("localhost:8002")
21 | swagger.getBasePath() should be ("/api")
22 |
23 | val info = swagger.getInfo()
24 |
25 | info should not be (null)
26 | info.getVersion() should be ("1.0.0")
27 | info.getTitle() should be ("Swagger Petstore")
28 | info.getContact() should not be (null)
29 | info.getContact().getEmail() should be ("apiteam@swagger.io")
30 | info.getLicense() should not be (null)
31 | info.getLicense().getName() should be ("Apache 2.0")
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/model/Owner.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Owner")
22 | public class Owner {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-subresource/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/runServer.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PORT=9999
4 |
5 | if [[ $# -eq 1 ]] ; then
6 | PORT=${1}
7 | fi
8 |
9 | mvn package jetty:run -Djetty.port=${PORT}
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private final int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs-wink/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=info, stdout, R
2 |
3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5 |
6 | # Pattern to output the caller's file name and line number.
7 | log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}] [%-5p] [%t] [%c{1}] %m%n
8 |
9 | log4j.appender.R=org.apache.log4j.RollingFileAppender
10 | log4j.appender.R.File=jetty.log
11 |
12 | log4j.appender.R.MaxFileSize=100MB
13 | # Keep one backup file
14 | log4j.appender.R.MaxBackupIndex=1
15 |
16 | log4j.appender.R.layout=org.apache.log4j.PatternLayout
17 | log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}] [%-5p] [%t] [%c{1}] %m%n
--------------------------------------------------------------------------------
/java/java-jaxrs/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/model/Car.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.model;
2 |
3 | import javax.xml.bind.annotation.XmlRootElement;
4 |
5 | @XmlRootElement(name = "Car")
6 | public class Car extends Vehicle {
7 | private Integer seats;
8 |
9 | public Integer getSeats() {
10 | return seats;
11 | }
12 |
13 | public void setSeats(Integer seats) {
14 | this.seats = seats;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/model/Cat.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.model;
2 |
3 | import javax.xml.bind.annotation.XmlRootElement;
4 |
5 | @XmlRootElement(name = "Cat")
6 | public class Cat extends Pet {
7 |
8 | String catBreed;
9 |
10 | public String getCatBreed() {
11 | return catBreed;
12 | }
13 |
14 | public void setCatBreed(String catBreed) {
15 | this.catBreed = catBreed;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jaxrs/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jaxrs/src/test/scala/ResourceListingIT.scala:
--------------------------------------------------------------------------------
1 | import io.swagger.models._
2 |
3 | import io.swagger.util.Json
4 |
5 | import org.junit.runner.RunWith
6 |
7 | import org.scalatest.junit.JUnitRunner
8 | import org.scalatest.FlatSpec
9 | import org.scalatest.Matchers
10 |
11 | import java.net.URL
12 |
13 | import scala.collection.JavaConversions._
14 |
15 | @RunWith(classOf[JUnitRunner])
16 | class ResourceListingIT extends FlatSpec with Matchers {
17 | it should "read a resource listing" in {
18 | val swagger = Json.mapper().readValue(new URL("http://localhost:8002/api/swagger.json"), classOf[Swagger])
19 |
20 | swagger.getHost() should be ("localhost:8002")
21 | swagger.getBasePath() should be ("/api")
22 |
23 | val info = swagger.getInfo()
24 |
25 | info should not be (null)
26 | info.getVersion() should be ("1.0.0")
27 | info.getTitle() should be ("Swagger Petstore")
28 | info.getContact() should not be (null)
29 | info.getContact().getEmail() should be ("apiteam@swagger.io")
30 | info.getLicense() should not be (null)
31 | info.getLicense().getName() should be ("Apache 2.0")
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/java/java-jersey-governator/README.md:
--------------------------------------------------------------------------------
1 | # Swagger, Jersey, Governator Sample App
2 |
3 | This app shows you how to combine Swagger, Jersey 1.X, and [Governator](https://github.com/Netflix/governator)
4 |
5 | ### To run (with Maven)
6 | To run the server, run this task:
7 |
8 | ```
9 | mvn package jetty:run-war
10 | ```
11 |
12 | This will start Jetty embedded on port 8002.
13 |
14 | ### Testing the server
15 | Once started, you can navigate to http://localhost:8002/swagger.json to view the Swagger Resource Listing.
16 | This tells you that the server is up and ready to demonstrate Swagger.
17 |
18 |
19 | ### Using the UI
20 | There is an HTML5-based API tool bundled in this sample--you can view it it at [http://localhost:8002/docs](http://localhost:8002/docs). This lets you inspect the API using an interactive UI. You can access the source of this code from [here](https://github.com/swagger-api/swagger-ui)
21 |
22 | ### Using the Karyon 2 Admin Page
23 |
24 | You can view the Karyon 2 Admin Page at [http://localhost:8077/adminres](http://localhost:8077/adminres). This page gives you access to debug/admin features provided by karyon.
25 |
26 |
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/StartServer.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample;
2 |
3 | import com.google.inject.Injector;
4 | import com.netflix.governator.InjectorBuilder;
5 | import com.netflix.governator.guice.servlet.GovernatorServletContextListener;
6 | import io.swagger.sample.modules.PetstoreModule;
7 | import io.swagger.sample.modules.SwaggerModule;
8 | import netflix.adminresources.resources.KaryonWebAdminModule;
9 |
10 | /**
11 | * Created by rbolles on 2/18/16.
12 | */
13 | public class StartServer extends GovernatorServletContextListener {
14 |
15 | @Override
16 | protected Injector createInjector() throws Exception {
17 | return InjectorBuilder.fromModules(
18 | new PetstoreModule(),
19 | new SwaggerModule(),
20 | new KaryonWebAdminModule()
21 | ).createInjector();
22 | }
23 | }
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception {
20 | private int code;
21 |
22 | public ApiException (int code, String msg) {
23 | super(msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException {
20 | private int code;
21 |
22 | public BadRequestException (int code, String msg) {
23 | super(code, msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 |
22 | public NotFoundException (int code, String msg) {
23 | super(code, msg);
24 | this.code = code;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.XmlElement;
20 | import javax.xml.bind.annotation.XmlRootElement;
21 |
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | public long getId() {
27 | return id;
28 | }
29 |
30 | public void setId(long id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 | }
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.XmlElement;
20 | import javax.xml.bind.annotation.XmlRootElement;
21 |
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | public long getId() {
27 | return id;
28 | }
29 |
30 | public void setId(long id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 | }
--------------------------------------------------------------------------------
/java/java-jersey-governator/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | guiceFilter
9 | com.google.inject.servlet.GuiceFilter
10 |
11 |
12 |
13 | guiceFilter
14 | /*
15 |
16 |
17 |
18 | io.swagger.sample.StartServer
19 |
20 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-servlet/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-simple-webxml/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi-use-basepath/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs-multi/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-jaxrs/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jersey-spring/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey-spring/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/Application.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample;
2 |
3 | import org.glassfish.jersey.server.ResourceConfig;
4 |
5 | public class Application extends ResourceConfig {
6 | public Application() {
7 | packages("io.swagger.sample.resource").
8 | packages("io.swagger.sample.util").
9 | register(io.swagger.jaxrs.listing.ApiListingResource.class).
10 | register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-jersey2-guice/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | io.swagger.sample.SwaggerExampleGuiceContextListener
8 |
9 |
10 |
11 | guiceFilter
12 | com.google.inject.servlet.GuiceFilter
13 |
14 |
15 |
16 | guiceFilter
17 | /api/*
18 |
19 |
20 |
--------------------------------------------------------------------------------
/java/java-jersey2/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/model/AuthenticationInfo.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.model;
2 |
3 | import io.swagger.annotations.ApiParam;
4 |
5 | import javax.ws.rs.*;
6 |
7 | public class AuthenticationInfo {
8 | @HeaderParam("X-TOKEN")
9 | @ApiParam("The an expiring token assigned to a user")
10 | protected String token;
11 | @HeaderParam("X-REQUEST-HASH")
12 | @ApiParam("A HMAC-SHA hash based on the request being made")
13 | protected String hash;
14 |
15 | public String getHash() {
16 | return token;
17 | }
18 | public void setHash(String token) {
19 | this.token = token;
20 | }
21 |
22 | public String getToken() {
23 | return token;
24 | }
25 | public void setToken(String token) {
26 | this.token = token;
27 | }
28 | }
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/java/io/swagger/sample/resource/QueryResultBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.resource;
18 |
19 | import javax.ws.rs.*;
20 |
21 | public class QueryResultBean {
22 | @QueryParam("skip")
23 | private Integer skip;
24 |
25 | @QueryParam("limit")
26 | private Integer limit;
27 |
28 |
29 | public Integer getSkip() {
30 | return skip;
31 | }
32 | public void setSkip(Integer skip) {
33 | this.skip = skip;
34 | }
35 |
36 | public Integer getLimit() {
37 | return limit;
38 | }
39 | public void setLimit(Integer limit) {
40 | this.limit = limit;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/java/java-jersey2/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-mule/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-mule/mule-project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | mule-swagger-integration
4 |
5 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/app/log4j.properties:
--------------------------------------------------------------------------------
1 | # Default log level
2 | log4j.rootLogger=DEBUG,applogger
3 | log4j.appender.applogger=org.apache.log4j.DailyRollingFileAppender
4 | log4j.appender.applogger.DatePattern=yyyyMMdd
5 | log4j.appender.applogger.File=${log_dir}/mule-app-swagger-integration-v1.0.log
6 | log4j.appender.applogger.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.applogger.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
8 |
9 | ################################################
10 | # You can set custom log levels per-package here
11 | ################################################
12 |
13 | # CXF is used heavily by Mule for web services
14 | log4j.logger.org.apache.cxf=WARN
15 |
16 | # Apache Commons tend to make a lot of noise which can clutter the log.
17 | log4j.logger.org.apache=WARN
18 |
19 | log4j.logger.io.swagger=INFO
20 |
21 | # Reduce startup noise
22 | log4j.logger.org.springframework.beans.factory=WARN
23 |
24 | # Mule classes
25 | log4j.logger.org.mule=DEBUG
26 | log4j.logger.com.mulesoft=DEBUG
27 |
28 | # Reduce DM verbosity
29 | log4j.logger.org.jetel=WARN
30 | log4j.logger.Tracking=WARN
31 | log4j.logger.org.mortbay=INFO
32 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/app/mule-deploy.properties:
--------------------------------------------------------------------------------
1 | redeployment.enabled=true
2 | encoding=UTF-8
3 | domain=default
4 | config.resources=mule-swagger-integration.xml
5 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-mule/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-mule/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-mule/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/java/java-mule/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter
--------------------------------------------------------------------------------
/java/java-mule/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | Access-Control-Allow-Origin=*
2 | Access-Control-Allow-Headers=Origin, X-Requested-With, Content-Type, Accept
--------------------------------------------------------------------------------
/java/java-mule/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Default log level
2 | log4j.rootLogger=DEBUG,applogger
3 | log4j.appender.applogger=org.apache.log4j.DailyRollingFileAppender
4 | log4j.appender.applogger.DatePattern=yyyyMMdd
5 | log4j.appender.applogger.File=${log_dir}/mule-app-swagger-integration-v1.0.log
6 | log4j.appender.applogger.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.applogger.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
8 |
9 | ################################################
10 | # You can set custom log levels per-package here
11 | ################################################
12 |
13 | # CXF is used heavily by Mule for web services
14 | log4j.logger.org.apache.cxf=WARN
15 |
16 | # Apache Commons tend to make a lot of noise which can clutter the log.
17 | log4j.logger.org.apache=WARN
18 |
19 | log4j.logger.io.swagger=INFO
20 |
21 | # Reduce startup noise
22 | log4j.logger.org.springframework.beans.factory=WARN
23 |
24 | # Mule classes
25 | log4j.logger.org.mule=INFO
26 | log4j.logger.com.mulesoft=INFO
27 |
28 | # Reduce DM verbosity
29 | log4j.logger.org.jetel=WARN
30 | log4j.logger.Tracking=WARN
31 | log4j.logger.org.mortbay=INFO
--------------------------------------------------------------------------------
/java/java-mule/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-resteasy-filter/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy-filter/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-resteasy-spring/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy-spring/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-resteasy/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootCategory=ERROR, CONSOLE, LOGFILE
2 |
3 | log4j.logger.io.swagger=ERROR
4 | log4j.logger.org.atmosphere=ERROR
5 |
6 | # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
7 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
8 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
10 |
11 | # LOGFILE is set to be a File appender using a PatternLayout.
12 | log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
13 | log4j.appender.LOGFILE.File=logs/swagger.log
14 | log4j.appender.LOGFILE.Append=true
15 | log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
17 | log4j.appender.LOGFILE.MaxFileSize=10MB
18 | log4j.appender.LOGFILE.MaxBackupIndex=10
19 |
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException{
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/java/io/swagger/sample/model/Category.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Category")
22 | public class Category {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/java/io/swagger/sample/model/Tag.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.model;
18 |
19 | import javax.xml.bind.annotation.*;
20 |
21 | @XmlRootElement(name = "Tag")
22 | public class Tag {
23 | private long id;
24 | private String name;
25 |
26 | @XmlElement(name = "id")
27 | public long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(long id) {
32 | this.id = id;
33 | }
34 |
35 | @XmlElement(name = "name")
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 | }
--------------------------------------------------------------------------------
/java/java-resteasy/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-servlet/src/main/java/io/swagger/sample/util/ApiOriginFilter.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.util;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.Filter;
6 | import javax.servlet.FilterChain;
7 | import javax.servlet.FilterConfig;
8 | import javax.servlet.ServletException;
9 | import javax.servlet.ServletRequest;
10 | import javax.servlet.ServletResponse;
11 | import javax.servlet.http.HttpServletResponse;
12 |
13 | public class ApiOriginFilter implements Filter {
14 |
15 | @Override
16 | public void init(FilterConfig filterConfig) throws ServletException {
17 |
18 | }
19 |
20 | @Override
21 | public void doFilter(ServletRequest request, ServletResponse response,
22 | FilterChain chain) throws IOException, ServletException {
23 | final HttpServletResponse res = (HttpServletResponse) response;
24 | res.addHeader("Access-Control-Allow-Origin:", "*");
25 | res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
26 | res.addHeader("Access-Control-Allow-Headers", "Content-Type");
27 | chain.doFilter(request, response);
28 | }
29 |
30 | @Override
31 | public void destroy() {
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/java/java-servlet/src/main/resource/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/java-spring-boot/README.md:
--------------------------------------------------------------------------------
1 | # Swagger + SpringFox + SpringBoot example
2 |
3 | This is a simple example to demonstrate Swagger with Spring Boot. The integration
4 | is handled by SpringFox, a 3rd party library for enabling Swagger on Spring MVC projects.
5 |
6 | For more information on SpringFox, pleas visit [http://springfox.io](http://springfox.io)
7 |
8 | ## Building
9 |
10 | This project requires Java 7 or greater.
11 |
12 | To build:
13 |
14 | ```
15 | mvn clean package
16 | ```
17 |
18 | This produces an exectuable jar in the `target` folder.
19 |
20 | To run:
21 |
22 | ```
23 | java -jar target/swaggerhub-spring-boot-sample-1.0.0-SNAPSHOT.jar
24 | ```
25 |
26 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class ApiException extends Exception{
20 | private int code;
21 | public ApiException (int code, String msg) {
22 | super(msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class BadRequestException extends ApiException {
20 | private int code;
21 | public BadRequestException (int code, String msg) {
22 | super(code, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 SmartBear Software
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.swagger.sample.exception;
18 |
19 | public class NotFoundException extends ApiException {
20 | private int code;
21 | public NotFoundException (int code, String msg) {
22 | super(404, msg);
23 | this.code = code;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/models/Category.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.models;
2 |
3 | import javax.xml.bind.annotation.XmlElement;
4 | import javax.xml.bind.annotation.XmlRootElement;
5 |
6 | @XmlRootElement(name = "Category")
7 | public class Category {
8 | private long id;
9 | private String name;
10 |
11 | @XmlElement(name = "id")
12 | public long getId() {
13 | return id;
14 | }
15 |
16 | public void setId(long id) {
17 | this.id = id;
18 | }
19 |
20 | @XmlElement(name = "name")
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 | }
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/models/Tag.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.models;
2 |
3 | import javax.xml.bind.annotation.XmlElement;
4 | import javax.xml.bind.annotation.XmlRootElement;
5 |
6 | @XmlRootElement(name = "Tag")
7 | public class Tag {
8 | private long id;
9 | private String name;
10 |
11 | @XmlElement(name = "id")
12 | public long getId() {
13 | return id;
14 | }
15 |
16 | public void setId(long id) {
17 | this.id = id;
18 | }
19 |
20 | @XmlElement(name = "name")
21 | public String getName() {
22 | return name;
23 | }
24 |
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 | }
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/resource/AbstractResource.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.resource;
2 |
3 | import io.swagger.sample.exception.NotFoundException;
4 | import io.swagger.sample.models.ApiResponse;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.web.bind.annotation.CrossOrigin;
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
8 | import org.springframework.web.bind.annotation.ResponseStatus;
9 |
10 | public class AbstractResource {
11 |
12 | @CrossOrigin(allowedHeaders = "foo", origins = "*")
13 | @ResponseStatus(HttpStatus.NOT_FOUND)
14 | @ExceptionHandler(NotFoundException.class)
15 | public ApiResponse exception(NotFoundException e) {
16 | return new ApiResponse(ApiResponse.ERROR, e.getMessage());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/java/io/swagger/sample/resource/StoreResource.java:
--------------------------------------------------------------------------------
1 | package io.swagger.sample.resource;
2 |
3 | /**
4 | * Created by tony on 9/9/16.
5 | */
6 | public class StoreResource {
7 | }
8 |
--------------------------------------------------------------------------------
/java/java-spring-boot/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # prefix for all requests
2 | server.contextPath=/v2
3 |
4 | # location of the swagger json
5 | springfox.documentation.swagger.v2.path=/swagger.json
--------------------------------------------------------------------------------
/java/swagger-petstore-v2/README.md:
--------------------------------------------------------------------------------
1 | # Swagger Sample Petstore App
2 |
3 | This project has been moved to https://github.com/swagger-api/swagger-petstore/tree/v2
4 |
5 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/README.md:
--------------------------------------------------------------------------------
1 | # Swagger Playframework Sample App
2 |
3 | ## Overview
4 | This is a scala project to build a stand-alone server which implements the OpenAPI Spec. You can find out
5 | more about both the spec and the framework at http://swagger.io. There is an online version of this
6 | server at [http://petstore.swagger.io](http://petstore.swagger.io)
7 |
8 | ## Version compatibility
9 | =======
10 | This version is compatible with Play 2.4.0 and Swagger 1.5.0-SNAPSHOT
11 |
12 | ### To build Swagger from source (optional)
13 | Please follow instructions to build the top-level [swagger-core project](https://github.com/swagger-api/swagger-play)
14 |
15 | ### To run
16 | The swagger-play2 module lives in maven central:
17 |
18 | ```scala
19 | val appDependencies: Seq[sbt.ModuleID] = Seq(
20 | /* your other dependencies */
21 | "io.swagger" %% "swagger-play2" % "1.5.0-SNAPSHOT"
22 | )
23 | ```
24 |
25 | You can run the sample app as such:
26 |
27 | ```
28 | sbt run
29 | ```
30 | or
31 | ```
32 | activator testProd
33 | ````
34 |
35 | The application will listen on port 9000 and respond to `http://localhost:9000/swagger.json`
36 |
37 | You can test the sample app as such:
38 |
39 |
40 | ````
41 | activator test
42 | ````
--------------------------------------------------------------------------------
/scala/scala-play2.4/app/models/Category.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 | @ApiModel(value="Category",description="category of a pet")
24 | case class Category(
25 | @(ApiModelProperty @field)(position=1)id: Long,
26 | @(ApiModelProperty @field)(position=2)name: String)
27 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/app/models/Order.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import java.util.Date
22 |
23 | import scala.annotation.meta.field
24 |
25 | @ApiModel("Order")
26 | case class Order (
27 | @(ApiModelProperty @field)(position=1)id: Long,
28 | @(ApiModelProperty @field)(position=2)petId: Long,
29 | @(ApiModelProperty @field)(position=3)quantity: Int,
30 | @(ApiModelProperty @field)(position=4)shipDate: Date,
31 | @(ApiModelProperty @field)(position=5)status: String
32 | )
33 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/app/models/Pet.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 | @ApiModel("Pet")
24 | case class Pet(
25 | @(ApiModelProperty @field)(position=1, value="id")id: Long,
26 | @(ApiModelProperty @field)(position=2)category: Category,
27 | @(ApiModelProperty @field)(position=3)name: String,
28 | @(ApiModelProperty @field)(position=4)photoUrls: List[String],
29 | @(ApiModelProperty @field)(position=5)tags: List[Tag],
30 | @(ApiModelProperty @field)(position=6)status: String
31 | )
32 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/app/models/Tag.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 |
24 | @ApiModel("Tag")
25 | case class Tag (
26 | @(ApiModelProperty @field)(position=1)id: Long,
27 | @(ApiModelProperty @field)(position=2)name: String)
28 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/app/value/ApiResponse.scala:
--------------------------------------------------------------------------------
1 | package value
2 |
3 | import javax.xml.bind.annotation._
4 |
5 | object ApiResponse {
6 | val ERROR = 1
7 | val WARNING = 2
8 | val INFO = 3
9 | val OK = 4
10 | val TOO_BUSY = 5
11 | }
12 |
13 | @XmlRootElement
14 | class ApiResponse(@XmlElement var code: Int, @XmlElement var message: String) {
15 | def this() = this(0, null)
16 |
17 | @XmlTransient
18 | def getCode(): Int = code
19 | def setCode(code: Int) = this.code = code
20 |
21 | def getType(): String = code match {
22 | case ApiResponse.ERROR => "error"
23 | case ApiResponse.WARNING => "warning"
24 | case ApiResponse.INFO => "info"
25 | case ApiResponse.OK => "ok"
26 | case ApiResponse.TOO_BUSY => "too busy"
27 | case _ => "unknown"
28 | }
29 | def setType(`type`: String) = {}
30 |
31 | def getMessage(): String = message
32 | def setMessage(message: String) = this.message = message
33 | }
34 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %coloredLevel - %logger - %message%n%xException
8 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.9
2 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | // The Play plugin
2 | addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")
3 |
4 | // Web plugins
5 | addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
6 | addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
7 | addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
8 | addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
9 | addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
10 | addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
11 |
12 | // Play enhancer - this automatically generates getters/setters for public fields
13 | // and rewrites accessors of these fields to use the getters/setters. Remove this
14 | // plugin if you prefer not to have this feature, or disable on a per project
15 | // basis using disablePlugins(PlayEnhancer) in your build.sbt
16 | addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
17 |
18 | // Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
19 | // enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
20 | // Play enhancer, regardless of whether the line above is commented out or not.
21 | // addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "2.0.0")
22 |
23 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
24 |
--------------------------------------------------------------------------------
/scala/scala-play2.4/public/images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/scala/scala-play2.4/public/images/favicon.png
--------------------------------------------------------------------------------
/scala/scala-play2.6/README.md:
--------------------------------------------------------------------------------
1 | # Swagger Playframework Sample App
2 |
3 | ## Overview
4 | This is a scala project to build a stand-alone server which implements the OpenAPI Spec. You can find out
5 | more about both the spec and the framework at http://swagger.io. There is an online version of this
6 | server at [http://petstore.swagger.io](http://petstore.swagger.io)
7 |
8 | ## Version compatibility
9 | =======
10 | This version is compatible with Play 2.6 and Swagger 1.5.X
11 |
12 |
13 | ### To run
14 | The swagger-play2 module lives in maven central:
15 |
16 | ```scala
17 | val appDependencies: Seq[sbt.ModuleID] = Seq(
18 | /* your other dependencies */
19 | "io.swagger" %% "swagger-play2" % "1.6.1"
20 | )
21 | ```
22 |
23 | You can run the sample app as such:
24 |
25 | ```
26 | sbt run
27 | ```
28 | or
29 | ```
30 | activator testProd
31 | ````
32 |
33 | The application will listen on port 9000 and respond to `http://localhost:9000/swagger.json`
34 |
35 | You can test the sample app as such:
36 |
37 |
38 | ````
39 | activator test
40 | ````
--------------------------------------------------------------------------------
/scala/scala-play2.6/app/models/Category.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 | @ApiModel(value="Category",description="category of a pet")
24 | case class Category(
25 | @(ApiModelProperty @field)(position=1)id: Long,
26 | @(ApiModelProperty @field)(position=2)name: String)
27 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/app/models/Order.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import java.util.Date
22 |
23 | import scala.annotation.meta.field
24 |
25 | @ApiModel("Order")
26 | case class Order (
27 | @(ApiModelProperty @field)(position=1)id: Long,
28 | @(ApiModelProperty @field)(position=2)petId: Long,
29 | @(ApiModelProperty @field)(position=3)quantity: Int,
30 | @(ApiModelProperty @field)(position=4)shipDate: Date,
31 | @(ApiModelProperty @field)(position=5)status: String
32 | )
33 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/app/models/Pet.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 | @ApiModel("Pet")
24 | case class Pet(
25 | @(ApiModelProperty @field)(position=1, value="id")id: Long,
26 | @(ApiModelProperty @field)(position=2)category: Category,
27 | @(ApiModelProperty @field)(position=3)name: String,
28 | @(ApiModelProperty @field)(position=4)photoUrls: List[String],
29 | @(ApiModelProperty @field)(position=5)tags: List[Tag],
30 | @(ApiModelProperty @field)(position=6)status: String
31 | )
32 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/app/models/Tag.scala:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Reverb Technologies, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package models
18 |
19 | import io.swagger.annotations._
20 |
21 | import scala.annotation.meta.field
22 |
23 |
24 | @ApiModel("Tag")
25 | case class Tag (
26 | @(ApiModelProperty @field)(position=1)id: Long,
27 | @(ApiModelProperty @field)(position=2)name: String)
28 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/app/value/ApiResponse.scala:
--------------------------------------------------------------------------------
1 | package value
2 |
3 | import javax.xml.bind.annotation._
4 |
5 | object ApiResponse {
6 | val ERROR = 1
7 | val WARNING = 2
8 | val INFO = 3
9 | val OK = 4
10 | val TOO_BUSY = 5
11 | }
12 |
13 | @XmlRootElement
14 | class ApiResponse(@XmlElement var code: Int, @XmlElement var message: String) {
15 | def this() = this(0, null)
16 |
17 | @XmlTransient
18 | def getCode(): Int = code
19 | def setCode(code: Int) = this.code = code
20 |
21 | def getType(): String = code match {
22 | case ApiResponse.ERROR => "error"
23 | case ApiResponse.WARNING => "warning"
24 | case ApiResponse.INFO => "info"
25 | case ApiResponse.OK => "ok"
26 | case ApiResponse.TOO_BUSY => "too busy"
27 | case _ => "unknown"
28 | }
29 | def setType(`type`: String) = {}
30 |
31 | def getMessage(): String = message
32 | def setMessage(message: String) = this.message = message
33 | }
34 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %coloredLevel - %logger - %message%n%xException
8 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=1.1.2
2 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | // The Play plugin
2 | addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.6")
3 |
4 | // Web plugins
5 | addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.2")
6 | addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
7 | addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.6")
8 | addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.10")
9 | addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.3")
10 | addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.2")
11 |
12 | // Play enhancer - this automatically generates getters/setters for public fields
13 | // and rewrites accessors of these fields to use the getters/setters. Remove this
14 | // plugin if you prefer not to have this feature, or disable on a per project
15 | // basis using disablePlugins(PlayEnhancer) in your build.sbt
16 | addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.2.2")
17 |
18 | // Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
19 | // enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
20 | // Play enhancer, regardless of whether the line above is commented out or not.
21 | // addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "2.0.0")
22 |
23 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
24 |
--------------------------------------------------------------------------------
/scala/scala-play2.6/public/images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-samples/cdef17ac1137902226f51e15bdfc8e4ec329bd7d/scala/scala-play2.6/public/images/favicon.png
--------------------------------------------------------------------------------