Skip to content

Commit

Permalink
Merge pull request #58 from swagger-api/develop
Browse files Browse the repository at this point in the history
merge from develop 2.0 for release
  • Loading branch information
fehguy committed Jun 7, 2015
2 parents 65e0086 + 9eba5fd commit 93b0db9
Show file tree
Hide file tree
Showing 124 changed files with 16,857 additions and 15,412 deletions.
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright 2015 SmartBear Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
## Overview
This is the swagger parser project, which reads swagger specifications into current Java POJOs. It also provides a simple framework to add additional converters from different formats into the Swagger objects, making the entire toolchain available.

## What's Swagger?

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.


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


Expand All @@ -13,7 +18,7 @@ Using the swagger-parser is simple. Once included in your project, you can read

```java
import io.swagger.parser.SwaggerParser;
import com.wordnik.swagger.models.Swagger;
import io.swagger.models.Swagger;

// ... your code

Expand All @@ -34,7 +39,7 @@ And with the swagger-compat-spec-parser module, you can read older formats, and

If your swagger resource is protected, you can pass headers in the request:
```java
import com.wordnik.swagger.models.auth.AuthorizationValue;
import io.swagger.models.auth.AuthorizationValue;

// ... your code

Expand Down
143 changes: 72 additions & 71 deletions modules/swagger-compat-spec-parser/pom.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser-project</artifactId>
<version>1.0.8</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser-project</artifactId>
<version>1.0.7</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>1.0.7</version>
<packaging>jar</packaging>
<name>swagger-compat-spec-parser</name>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bsh</artifactId>
<groupId>org.beanshell</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>1.0.8</version>
<packaging>jar</packaging>
<name>swagger-compat-spec-parser</name>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bsh</artifactId>
<groupId>org.beanshell</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.reflect.ParameterizedType;

public abstract class AbstractSwaggerDeserializer<T> implements SwaggerDeserializer<T> {
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({"unchecked"})
protected final Class<T> clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
protected final ObjectMapper objectMapper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.swagger.models;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Map;
import java.util.HashMap;
import java.util.Map;

/**
* Created by ron on 11/04/14.
Expand All @@ -13,24 +14,25 @@ public enum AuthorizationType {

private static Map<String, AuthorizationType> names = new HashMap<String, AuthorizationType>();

static {
names.put("basicAuth", BASIC_AUTH);
names.put("apiKey", APIKEY);
names.put("oauth2", OAUTH2);
}

@JsonCreator
public static AuthorizationType forValue(String value) {
return names.get(value.toLowerCase());
return names.get(value.toLowerCase());
}

@JsonValue
public String toValue() {
for (Map.Entry<String, AuthorizationType> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey();
}
for (Map.Entry<String, AuthorizationType> entry : names.entrySet()) {
if (entry.getValue() == this) {
return entry.getKey();
}
}

return null; // or fail
}

return null; // or fail
static {
names.put("basicAuth", BASIC_AUTH);
names.put("apiKey", APIKEY);
names.put("oauth2", OAUTH2);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.swagger.models;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Map;
import java.util.HashMap;
import java.util.Map;

/**
* Created by ron on 11/04/14.
Expand All @@ -13,36 +14,38 @@ public enum Format {

private static Map<String, Format> names = new HashMap<String, Format>();

static {
names.put("int32", INT32);
names.put("int64", INT64);
names.put("float", FLOAT);
names.put("double", DOUBLE);
names.put("byte", BYTE);
names.put("date", DATE);
names.put("date-time", DATE_TIME);
}

@JsonCreator
public static Format forValue(String value) {
return names.get(value.toLowerCase());
return names.get(value.toLowerCase());
}

@JsonValue
public String toValue() {
for (Map.Entry<String, Format> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey();
}
for (Map.Entry<String, Format> entry : names.entrySet()) {
if (entry.getValue() == this) {
return entry.getKey();
}
}

return null; // or fail
return null; // or fail
}

public String toString() {
for (Map.Entry<String, Format> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey().toLowerCase();
}
return null;
for (Map.Entry<String, Format> entry : names.entrySet()) {
if (entry.getValue() == this) {
return entry.getKey().toLowerCase();
}
}
return null;
}

static {
names.put("int32", INT32);
names.put("int64", INT64);
names.put("float", FLOAT);
names.put("double", DOUBLE);
names.put("byte", BYTE);
names.put("date", DATE);
names.put("date-time", DATE_TIME);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.swagger.models;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Map;
import java.util.HashMap;
import java.util.Map;

/**
* Created by ron on 11/04/14.
Expand All @@ -13,28 +14,29 @@ public enum Method {

private static Map<String, Method> names = new HashMap<String, Method>();

static {
names.put("get", GET);
names.put("put", PUT);
names.put("post", POST);
names.put("delete", DELETE);
names.put("patch", PATCH);
names.put("options", OPTIONS);
names.put("head", HEAD);
}

@JsonCreator
public static Method forValue(String value) {
return names.get(value.toLowerCase());
return names.get(value.toLowerCase());
}

@JsonValue
public String toValue() {
for (Map.Entry<String, Method> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey();
}
for (Map.Entry<String, Method> entry : names.entrySet()) {
if (entry.getValue() == this) {
return entry.getKey();
}
}

return null; // or fail
}

return null; // or fail
static {
names.put("get", GET);
names.put("put", PUT);
names.put("post", POST);
names.put("delete", DELETE);
names.put("patch", PATCH);
names.put("options", OPTIONS);
names.put("head", HEAD);
}
}
Loading

0 comments on commit 93b0db9

Please sign in to comment.