Skip to content

Commit ee6fbb4

Browse files
committed
Merge branch 'master' of github.com:wordnik/swagger-core
2 parents d5adefd + 20cc9a5 commit ee6fbb4

File tree

12 files changed

+68
-37
lines changed

12 files changed

+68
-37
lines changed

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
# Swagger Core library
22

3-
[![Build Status](https://travis-ci.org/wordnik/swagger-core.png)](https://travis-ci.org/wordnik/swagger-core)
3+
[![Build Status](https://travis-ci.org/swagger-api/swagger-core.png)](https://travis-ci.org/swagger-api/swagger-core)
44

55
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
66

77
Swagger-core is the Java/Scala implementation of Swagger. It supports *JAX-RS*, *plain Servlets*, and *Play Framework*.
88

9-
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for SpringMVC, other languages and more.
9+
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for SpringMVC, other languages and more.
1010

1111
## See the Wiki!
12-
The [github wiki](https://github.com/wordnik/swagger-core/wiki) contains documentation, samples, etc. Start there.
12+
The [github wiki](https://github.com/swagger-api/swagger-core/wiki) contains documentation, samples, etc. Start there.
1313

1414
## Support
1515
The following methods are available to obtain support for Swagger:
1616

1717
- [The Swagger Google Group](https://groups.google.com/forum/#!forum/swagger-swaggersocket) - This would normally be your first stop to get support for Swagger. Here you can find previously asked question, and ask new ones. When asking a question, please provide as much information as you can regarding the environment you use (development language, library, versions.
18-
- The [Issues tab](https://github.com/wordnik/swagger-core/issues?state=open) - Please open feature requests and bugs here. If you're not sure you encountered a bug, or if it's a general usage question, please use the Google Group mentioned above.
18+
- The [Issues tab](https://github.com/swagger-api/swagger-core/issues?state=open) - Please open feature requests and bugs here. If you're not sure you encountered a bug, or if it's a general usage question, please use the Google Group mentioned above.
1919
- IRC! you can find us on [freenode](http://webchat.freenode.net/?channels=swagger) in the channel #Swagger. You can talk with us directly there.
2020

2121

2222
## Get started with Swagger!
23-
See the guide on [getting started with swagger](https://github.com/wordnik/swagger-core/wiki/Adding-Swagger-to-your-API) to get started with adding swagger to your API.
23+
See the guide on [getting started with swagger](https://github.com/swagger-api/swagger-core/wiki/Adding-Swagger-to-your-API) to get started with adding swagger to your API.
2424

25-
## Compatability
26-
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-core project has the following compatibilies with the swagger specification:
25+
## Compatibility
26+
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-core project has the following compatibilities with the swagger specification:
2727

28-
Swagger core Version | Release Date | Swagger Spec compatability | Notes | Status
28+
Swagger core Version | Release Date | Swagger Spec compatibility | Notes | Status
2929
------------------------- | ------------ | -------------------------- | ----- | ----
30-
1.5.0 (in development) | n/a | 2.0 | [branch develop_2.0](https://github.com/wordnik/swagger-core/tree/develop_2.0) | [1.5.0 Milestone](https://github.com/wordnik/swagger-core/milestones/v1.5.0)
31-
1.3.10 | 2014-09-18 | 1.2 | [tag v1.3.10](https://github.com/wordnik/swagger-core/tree/v1.3.10)
32-
1.2.4 | 2013-06-19 | 1.1 | [tag swagger-project_2.10.0-1.2.4](https://github.com/wordnik/swagger-core/tree/swagger-project_2.10.0-1.2.4)
33-
1.0.0 | 2011-10-16 | 1.0 | [tag v1.0](https://github.com/wordnik/swagger-core/tree/v1.0)
30+
1.5.0 (in development) | n/a | 2.0 | [branch develop_2.0](https://github.com/swagger-api/swagger-core/tree/develop_2.0) | [1.5.0 Milestone](https://github.com/swagger-api/swagger-core/milestones/v1.5.0)
31+
1.3.10 | 2014-09-18 | 1.2 | [tag v1.3.10](https://github.com/swagger-api/swagger-core/tree/v1.3.10)
32+
1.2.4 | 2013-06-19 | 1.1 | [tag swagger-project_2.10.0-1.2.4](https://github.com/swagger-api/swagger-core/tree/swagger-project_2.10.0-1.2.4)
33+
1.0.0 | 2011-10-16 | 1.0 | [tag v1.0](https://github.com/swagger-api/swagger-core/tree/v1.0)
3434

3535
## Overview
36-
This is a project to build the swagger-core library, which is required for the Wordnik
37-
implementation of the Swagger spec. For more information about Wordnik's APIs, please
38-
visit http://developer.wordnik.com.
36+
This is a project to build the swagger-core library, which is required for the Wordnik implementation of the Swagger spec. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
3937

4038

4139
### Change History
42-
If you're interested in the change history of swagger and the swagger-core framework, see [here](https://github.com/wordnik/swagger-core/wiki/Changelog).
40+
If you're interested in the change history of swagger and the swagger-core framework, see [here](https://github.com/swagger-api/swagger-core/wiki/Changelog).
4341

4442

4543
### Prerequisites
@@ -69,11 +67,11 @@ Of course if you don't want to build locally you can grab artifacts from maven c
6967
## Sample Apps
7068
There are a number of sample apps in the `samples` folder:
7169

72-
[java-jaxrs](https://github.com/wordnik/swagger-core/tree/master/samples/java-jaxrs/README.md) Java-based swagger server with JAX-RS
70+
[java-jaxrs](https://github.com/swagger-api/swagger-core/tree/master/samples/java-jaxrs/README.md) Java-based swagger server with JAX-RS
7371

74-
[scala-jaxrs](https://github.com/wordnik/swagger-core/tree/master/samples/scala-jaxrs/README.md) Scala-based swagger server with JAX-RS
72+
[scala-jaxrs](https://github.com/swagger-api/swagger-core/tree/master/samples/scala-jaxrs/README.md) Scala-based swagger server with JAX-RS
7573

76-
[scala-jaxrs-apm](https://github.com/wordnik/swagger-core/tree/master/samples/scala-jaxrs-apm/README.md)
74+
[scala-jaxrs-apm](https://github.com/swagger-api/swagger-core/tree/master/samples/scala-jaxrs-apm/README.md)
7775
Scala-based swagger server using wordnik-oss utils for Application Performance Monitoring (APM)
7876

7977
To run a sample app after initial compile:
@@ -87,9 +85,9 @@ mvn jetty:run
8785

8886
And the [Play2](http://playframework.org) samples:
8987

90-
[java-play2](https://github.com/wordnik/swagger-core/tree/master/samples/java-play2) Java-based Play2 sample app
88+
[java-play2](https://github.com/swagger-api/swagger-core/tree/master/samples/java-play2) Java-based Play2 sample app
9189

92-
[scala-play2](https://github.com/wordnik/swagger-core/tree/master/samples/scala-play2) Scala-based Play2 sample app
90+
[scala-play2](https://github.com/swagger-api/swagger-core/tree/master/samples/scala-play2) Scala-based Play2 sample app
9391

9492
To run the Play2 sample apps:
9593

modules/swagger-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@
103103
<groupId>ch.qos.logback</groupId>
104104
<artifactId>logback-classic</artifactId>
105105
<version>${logback-version}</version>
106-
<scope>provided</scope>
106+
<scope>test</scope>
107107
</dependency>
108108
<dependency>
109109
<groupId>ch.qos.logback</groupId>
110110
<artifactId>logback-core</artifactId>
111111
<version>${logback-version}</version>
112-
<scope>provided</scope>
112+
<scope>test</scope>
113113
</dependency>
114114
</dependencies>
115115
</project>

modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ModelPropertyParser(cls: Class[_], t: Map[String, String] = Map.empty) (im
2727
}
2828
val processedFields = new ListBuffer[String]
2929
val excludedFieldTypes = new HashSet[String]
30-
final val positiveInfinity = "Infinity"
31-
final val negativeInfinity = "-Infinity"
30+
final val positiveInfinity = "infinity"
31+
final val negativeInfinity = "-infinity"
3232

3333
def parse = Option(cls).map(parseRecursive(_))
3434

@@ -378,21 +378,25 @@ class ModelPropertyParser(cls: Class[_], t: Map[String, String] = Map.empty) (im
378378
}
379379
else {
380380
val min = ranges(0) match {
381-
case e: String if(e == positiveInfinity) => Float.PositiveInfinity
382-
case e: String if(e == negativeInfinity) => Float.NegativeInfinity
381+
case e: String if(e.toLowerCase() == positiveInfinity) => Float.PositiveInfinity
382+
case e: String if(e.toLowerCase() == negativeInfinity) => Float.NegativeInfinity
383383
case e: String => e.toFloat
384384
}
385385
val max = ranges(1) match {
386-
case e: String if(e == positiveInfinity) => Float.PositiveInfinity
387-
case e: String if(e == negativeInfinity) => Float.NegativeInfinity
386+
case e: String if(e.toLowerCase() == positiveInfinity) => Float.PositiveInfinity
387+
case e: String if(e.toLowerCase() == negativeInfinity) => Float.NegativeInfinity
388388
case e: String => e.toFloat
389389
}
390390
AllowableRangeValues(min.toString, max.toString)
391391
}
392392
}
393393

394394
def getDataType(genericReturnType: Type, returnType: Type, isSimple: Boolean = false): String = {
395-
if (TypeUtil.isParameterizedList(genericReturnType)) {
395+
if (TypeUtil.isOptionalType(genericReturnType)) {
396+
val parameterizedType = genericReturnType.asInstanceOf[java.lang.reflect.ParameterizedType]
397+
val valueType = parameterizedType.getActualTypeArguments.head
398+
getDataType(valueType, valueType, isSimple)
399+
} else if (TypeUtil.isParameterizedList(genericReturnType)) {
396400
val parameterizedType = genericReturnType.asInstanceOf[java.lang.reflect.ParameterizedType]
397401
val valueType = parameterizedType.getActualTypeArguments.head
398402
"List[" + getDataType(valueType, valueType, isSimple) + "]"

modules/swagger-core/src/main/scala/com/wordnik/swagger/core/util/TypeUtil.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ object TypeUtil {
5959
}).asScala.toSet
6060
}
6161

62+
def isOptionalType(gt: Type): Boolean = {
63+
if (classOf[ParameterizedType].isAssignableFrom(gt.getClass)) {
64+
val tp = gt.asInstanceOf[ParameterizedType].getRawType
65+
(tp == classOf[Option[_]] || tp.asInstanceOf[Class[_]].getSimpleName.equals("Optional"))
66+
}
67+
else false
68+
}
69+
6270
def isParameterizedList(gt: Type): Boolean = {
6371
if (classOf[ParameterizedType].isAssignableFrom(gt.getClass)) {
6472
val tp = gt.asInstanceOf[ParameterizedType].getRawType

modules/swagger-core/src/main/resources/logback.xml renamed to modules/swagger-core/src/test/resources/logback-test.xml

File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package converter
2+
3+
import models._
4+
5+
import com.wordnik.swagger.converter._
6+
7+
import com.wordnik.swagger.core.util._
8+
import org.scalatest.{Matchers, FlatSpec}
9+
10+
class ModelWithOptionalFieldsTest extends FlatSpec with Matchers {
11+
val models = ModelConverters.readAll(classOf[ModelWithOptionalFields])
12+
JsonSerializer.asJson(models) should be ("""[{"id":"ModelWithOptionalFields","properties":{"string":{"type":"string"},"integer":{"type":"integer","format":"int32"}}}]""")
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package converter.models;
2+
3+
import com.google.common.base.Optional;
4+
5+
public class ModelWithOptionalFields {
6+
public Optional<String> string;
7+
public Optional<Integer> integer;
8+
}

modules/swagger-jaxrs/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@
6969
<groupId>ch.qos.logback</groupId>
7070
<artifactId>logback-classic</artifactId>
7171
<version>${logback-version}</version>
72-
<scope>provided</scope>
72+
<scope>test</scope>
7373
</dependency>
7474
<dependency>
7575
<groupId>ch.qos.logback</groupId>
7676
<artifactId>logback-core</artifactId>
7777
<version>${logback-version}</version>
78-
<scope>provided</scope>
78+
<scope>test</scope>
7979
</dependency>
8080
</dependencies>
8181
</project>

modules/swagger-jaxrs/src/main/resources/logback.xml renamed to modules/swagger-jaxrs/src/test/resources/logback-test.xml

File renamed without changes.

modules/swagger-oauth2-auth-server/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
<groupId>ch.qos.logback</groupId>
6767
<artifactId>logback-classic</artifactId>
6868
<version>${logback-version}</version>
69-
<scope>provided</scope>
69+
<scope>test</scope>
7070
</dependency>
7171
<dependency>
7272
<groupId>ch.qos.logback</groupId>
7373
<artifactId>logback-core</artifactId>
7474
<version>${logback-version}</version>
75-
<scope>provided</scope>
75+
<scope>test</scope>
7676
</dependency>
7777
</dependencies>
7878
<repositories>

0 commit comments

Comments
 (0)