forked from loafle/openapi-generator-original
update sample and test case for java feign
This commit is contained in:
parent
83dc5393cb
commit
f5693b6c73
@ -1,4 +1,4 @@
|
||||
# swagger-java-client
|
||||
# swagger-petstore-feign
|
||||
|
||||
## Requirements
|
||||
|
||||
@ -25,7 +25,7 @@ After the client libarary is installed/deployed, you can use it in your Maven pr
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-java-client</artifactId>
|
||||
<artifactId>swagger-petstore-feign</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -80,7 +80,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
pom.artifactId = 'swagger-java-client'
|
||||
pom.artifactId = 'swagger-petstore-feign'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-java-client</artifactId>
|
||||
<artifactId>swagger-petstore-feign</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-java-client</name>
|
||||
<name>swagger-petstore-feign</name>
|
||||
<version>1.0.0</version>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:swagger-api/swagger-mustache.git</connection>
|
||||
|
@ -1 +1 @@
|
||||
rootProject.name = "swagger-java-client"
|
||||
rootProject.name = "swagger-petstore-feign"
|
@ -8,7 +8,7 @@ import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class ApiClient {
|
||||
public interface Api {}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import feign.codec.EncodeException;
|
||||
import feign.codec.Encoder;
|
||||
import feign.RequestTemplate;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class FormAwareEncoder implements Encoder {
|
||||
public static final String UTF_8 = "utf-8";
|
||||
private static final String LINE_FEED = "\r\n";
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -4,14 +4,11 @@ import io.swagger.client.ApiClient;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
import io.swagger.client.model.ApiResponse;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import feign.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public interface PetApi extends ApiClient.Api {
|
||||
|
||||
|
||||
@ -69,8 +66,8 @@ public interface PetApi extends ApiClient.Api {
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a single pet
|
||||
* @param petId ID of pet to return
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
* @return Pet
|
||||
*/
|
||||
@RequestLine("GET /pet/{petId}")
|
||||
@ -93,7 +90,7 @@ public interface PetApi extends ApiClient.Api {
|
||||
"Content-type: application/x-www-form-urlencoded",
|
||||
"Accepts: application/json",
|
||||
})
|
||||
void updatePetWithForm(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status);
|
||||
void updatePetWithForm(@Param("petId") String petId, @Param("name") String name, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
@ -116,14 +113,13 @@ public interface PetApi extends ApiClient.Api {
|
||||
* @param petId ID of pet to update
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
* @return ApiResponse
|
||||
* @return void
|
||||
*/
|
||||
@RequestLine("POST /pet/{petId}/uploadImage")
|
||||
@Headers({
|
||||
"Content-type: multipart/form-data",
|
||||
"Accepts: application/json",
|
||||
})
|
||||
ApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file);
|
||||
|
||||
void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file);
|
||||
|
||||
}
|
||||
|
@ -5,12 +5,10 @@ import io.swagger.client.ApiClient;
|
||||
import java.util.Map;
|
||||
import io.swagger.client.model.Order;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import feign.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public interface StoreApi extends ApiClient.Api {
|
||||
|
||||
|
||||
@ -50,7 +48,7 @@ public interface StoreApi extends ApiClient.Api {
|
||||
"Content-type: application/json",
|
||||
"Accepts: application/json",
|
||||
})
|
||||
Order getOrderById(@Param("orderId") Long orderId);
|
||||
Order getOrderById(@Param("orderId") String orderId);
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
@ -65,5 +63,4 @@ public interface StoreApi extends ApiClient.Api {
|
||||
})
|
||||
void deleteOrder(@Param("orderId") String orderId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,12 +5,10 @@ import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.User;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import feign.*;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public interface UserApi extends ApiClient.Api {
|
||||
|
||||
|
||||
@ -119,5 +117,4 @@ public interface UserApi extends ApiClient.Api {
|
||||
})
|
||||
void deleteUser(@Param("username") String username);
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,16 +3,14 @@ package io.swagger.client.model;
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
@ -73,5 +71,3 @@ public class Category {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,16 +4,14 @@ import io.swagger.client.StringUtil;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
@ -21,6 +19,7 @@ public class Order {
|
||||
private Integer quantity = null;
|
||||
private Date shipDate = null;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
@ -33,13 +32,14 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status = null;
|
||||
private Boolean complete = false;
|
||||
private Boolean complete = null;
|
||||
|
||||
|
||||
/**
|
||||
@ -153,5 +153,3 @@ public enum StatusEnum {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,20 +2,18 @@ package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.StringUtil;
|
||||
import io.swagger.client.model.Category;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
@ -24,6 +22,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
@ -36,6 +35,7 @@ public enum StatusEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
@ -155,5 +155,3 @@ public enum StatusEnum {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,16 +3,14 @@ package io.swagger.client.model;
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
@ -73,5 +71,3 @@ public class Tag {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,16 +3,14 @@ package io.swagger.client.model;
|
||||
import io.swagger.client.StringUtil;
|
||||
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-09T22:59:22.180-05:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-10T16:26:30.730+08:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
@ -164,5 +162,3 @@ public class User {
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class PetApiTest {
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
|
||||
api.updatePetWithForm(fetched.getId(), "furt", null);
|
||||
api.updatePetWithForm(fetched.getId().toString(), "furt", null);
|
||||
Pet updated = api.getPetById(fetched.getId());
|
||||
|
||||
assertEquals(updated.getName(), "furt");
|
||||
|
@ -30,7 +30,7 @@ public class StoreApiTest {
|
||||
Order order = createOrder();
|
||||
api.placeOrder(order);
|
||||
|
||||
Order fetched = api.getOrderById(order.getId());
|
||||
Order fetched = api.getOrderById(order.getId().toString());
|
||||
assertEquals(order.getId(), fetched.getId());
|
||||
assertEquals(order.getPetId(), fetched.getPetId());
|
||||
assertEquals(order.getQuantity(), fetched.getQuantity());
|
||||
@ -41,12 +41,12 @@ public class StoreApiTest {
|
||||
Order order = createOrder();
|
||||
api.placeOrder(order);
|
||||
|
||||
Order fetched = api.getOrderById(order.getId());
|
||||
Order fetched = api.getOrderById(order.getId().toString());
|
||||
assertEquals(fetched.getId(), order.getId());
|
||||
|
||||
api.deleteOrder(String.valueOf(order.getId()));
|
||||
|
||||
api.getOrderById(order.getId());
|
||||
api.getOrderById(order.getId().toString());
|
||||
// fail("expected an error");
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,9 @@ public class UserApiTest {
|
||||
assertEquals(user1.getId(), fetched.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
// ignore for the time being, please refer to the following for more info:
|
||||
// https://github.com/swagger-api/swagger-codegen/issues/1660
|
||||
@Ignore @Test
|
||||
public void testLoginUser() throws Exception {
|
||||
User user = createUser();
|
||||
api.createUser(user);
|
||||
|
Loading…
x
Reference in New Issue
Block a user