Skip to content

Commit

Permalink
Merge 6562683 into 457ad0f
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherpard committed Jun 21, 2018
2 parents 457ad0f + 6562683 commit a3536c1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

<properties>
<seed.version>3.6.0</seed.version>

<compatibility.skip>true</compatibility.skip>

<bintray.package>swagger-addon</bintray.package>
<swagger-jersey.version>1.5.20</swagger-jersey.version>
</properties>

<build>
Expand Down Expand Up @@ -101,7 +100,7 @@
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.16</version>
<version>${swagger-jersey.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
Expand Down
25 changes: 18 additions & 7 deletions src/test/java/org/seedstack/swagger/SwaggerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
public class SwaggerIT {

private static final String BASE_URL = "http://localhost:9001";
private static final String SWAGGER_JSON = "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0.2\",\"title\":\"Test" +
" API\"},\"host\":\"localhost:9001\",\"schemes\":[\"http\"]," +
"\"paths\":{\"/hello/{name}\":{\"get\":{\"summary\":\"Say hello the user\",\"description\":\"\"," +
"\"operationId\":\"hello\",\"produces\":[\"text/plain\"],\"parameters\":[{\"name\":\"name\"," +
"\"in\":\"path\",\"description\":\"The user name\",\"required\":true,\"type\":\"string\"}]," +
"\"responses\":{\"200\":{\"description\":\"successful operation\",\"schema\":{\"type\":\"string\"}}}}}}}";
private static final String SWAGGER_JSON = "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0.2\","+
"\"title\":\"Test API\"},\"host\":\"localhost:9001\",\"schemes\":[\"http\"],"+
"\"paths\":{\"/hello/{name}\":{\"get\":{\"summary\":\"Say hello the user\"," +
"\"description\":\"\",\"operationId\":\"hello\",\"produces\":[\"text/plain\"]," +
"\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"description\":\"The user name\"," +
"\"required\":true,\"type\":\"string\"},{\"name\":\"surname\",\"in\":\"query\"," +
"\"description\":\"The user surnames\",\"required\":true,\"type\":\"array\","+
"\"items\":{\"type\":\"string\"},\"collectionFormat\":\"multi\"}],\"responses\":" +
"{\"200\":{\"description\":\"successful operation\",\"schema\":{\"type\":\"string\"}}}}}}}";
private static final String SWAGGER_YAML = "---\n" +
"swagger: \"2.0\"\n" +
"info:\n" +
Expand All @@ -51,6 +54,14 @@ public class SwaggerIT {
" description: \"The user name\"\n" +
" required: true\n" +
" type: \"string\"\n" +
" - name: \"surname\"\n" +
" in: \"query\"\n" +
" description: \"The user surnames\"\n" +
" required: true\n" +
" type: \"array\"\n" +
" items:\n" +
" type: \"string\"\n" +
" collectionFormat: \"multi\"\n" +
" responses:\n" +
" 200:\n" +
" description: \"successful operation\"\n" +
Expand All @@ -62,7 +73,7 @@ public class SwaggerIT {
@Before
public void setUp() throws Exception {
launcher = Seed.getLauncher();
launcher.launch(new String[]{});
launcher.launch(new String[] {});
}

@Test
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/org/seedstack/swagger/fixtures/MyResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.stream.Collectors;

import javax.ws.rs.BeanParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand All @@ -24,7 +28,10 @@ public class MyResource {
@Path("/{name}")
@Produces("text/plain")
@ApiOperation(value = "Say hello the user", produces = "text/plain")
public String hello(@ApiParam(value = "The user name", required = true) @PathParam("name") String name) {
return "hello " + name;
public String hello(
@ApiParam(value = "The user name", required = true) @PathParam("name") String name,
@ApiParam(value = "The user surnames", required = true) @BeanParam MySurnameBean surnames) {
return "hello " + name + " "
+ surnames.getSurnames().stream().collect(Collectors.joining(" "));
}
}
23 changes: 23 additions & 0 deletions src/test/java/org/seedstack/swagger/fixtures/MySurnameBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright © 2013-2018, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.swagger.fixtures;

import java.util.List;

import javax.ws.rs.QueryParam;

public class MySurnameBean {

@QueryParam("surname")
private List<String> surnames;

public List<String> getSurnames() {
return surnames;
}

}

0 comments on commit a3536c1

Please sign in to comment.