getListOfItems();
21 |
22 | @Override
23 | public abstract Response testParamInheritance(
24 | @PathParam("firstParamAbstract") String firstParam,
25 | @ApiParam(required = true) @QueryParam("secondParamAbstract") String secondParam,
26 | String thirdParam);
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/MyResourceImpl.java:
--------------------------------------------------------------------------------
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 com.wordnik.jaxrs;
18 |
19 | import com.wordnik.sample.JavaRestResourceUtil;
20 | import com.wordnik.sample.data.PetData;
21 | import com.wordnik.sample.model.ListItem;
22 | import com.wordnik.sample.model.Pet;
23 |
24 | import io.swagger.annotations.ApiOperation;
25 | import io.swagger.annotations.ApiParam;
26 | import javax.ws.rs.POST;
27 | import javax.ws.rs.Path;
28 | import javax.ws.rs.PathParam;
29 | import javax.ws.rs.core.Response;
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | @Path("/myResourceImpl")
34 | public class MyResourceImpl extends MyResourceAbstract {
35 | static PetData petData = new PetData();
36 | static JavaRestResourceUtil ru = new JavaRestResourceUtil();
37 |
38 | //contrived example test case for swagger-maven-plugin issue #358
39 | /* (non-Javadoc)
40 | * @see com.wordnik.jaxrs.MyResource#getPetsById(java.lang.Long, java.lang.Long)
41 | */
42 | @Override
43 | public Response getPetsById(Long startId, Long endId)
44 | throws com.wordnik.sample.exception.NotFoundException {
45 | Pet pet = petData.getPetbyId(startId);
46 | if (pet != null) {
47 | return Response.ok().entity(pet).build();
48 | } else {
49 | throw new com.wordnik.sample.exception.NotFoundException(404, "Pet not found");
50 | }
51 | }
52 |
53 | //contrived example test case for swagger-maven-plugin issue #505
54 | /* (non-Javadoc)
55 | * @see com.wordnik.jaxrs.MyResource#getListOfItems()
56 | */
57 | @Path("list")
58 | @Override
59 | public List getListOfItems() {
60 | return new ArrayList();
61 | }
62 |
63 | //contrived example test case for swagger-maven-plugin issue #504
64 | /* (non-Javadoc)
65 | * @see com.wordnik.jaxrs.MyResource#testParamInheritance(java.lang.String, java.lang.String, java.lang.String)
66 | */
67 | @Path("{firstParamConcrete}/properties")
68 | @Override
69 | public Response testParamInheritance(
70 | @PathParam("firstParamConcrete") String firstParam,
71 | String secondParam,
72 | String thirdParam) {
73 | return Response.ok().build();
74 | }
75 |
76 | @POST
77 | @ApiOperation(value = "Insert a response", notes = "This is a contrived example")
78 | @Override
79 | public Response insertResource(@ApiParam(value = "Resource to insert", required = true) String resource) {
80 | return Response.ok().build();
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/PagedList.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import java.util.List;
4 |
5 | public class PagedList {
6 |
7 | private int pageNumber;
8 | private int totalItems;
9 | private List items;
10 |
11 | public PagedList(int pageNumber, int totalItems, List itemsOnPage) {
12 | this.pageNumber = pageNumber;
13 | this.totalItems = totalItems;
14 | this.items = itemsOnPage;
15 | }
16 |
17 | public int getPageNumber() {
18 | return pageNumber;
19 | }
20 |
21 | public int getTotalItems() {
22 | return totalItems;
23 | }
24 |
25 | public List getItems() {
26 | return items;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/ParentResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.wordnik.jaxrs;
7 |
8 | import io.swagger.annotations.Api;
9 | import io.swagger.annotations.ApiOperation;
10 | import javax.ws.rs.Path;
11 |
12 | /**
13 | *
14 | * @author pradeep.chaudhary
15 | */
16 | @Path("/v1.0")
17 | @Api
18 | public class ParentResource {
19 | @Path("/sub")
20 | @ApiOperation(value="SubResource")
21 | public SubResource getStudyResource() {
22 | return new SubResource();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/RootPathResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 |
6 | import javax.ws.rs.GET;
7 | import javax.ws.rs.Path;
8 |
9 | /**
10 | * @author andrewb
11 | */
12 | @Path("/")
13 | @Api(value = "/")
14 | public class RootPathResource {
15 | @GET
16 | @ApiOperation(value = "testingRootPathResource")
17 | public String testingRootPathResource() {
18 | return "testingRootPathResource";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/SubResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import com.wordnik.sample.model.User;
4 | import io.swagger.annotations.Api;
5 | import io.swagger.annotations.ApiOperation;
6 | import io.swagger.annotations.ApiParam;
7 | import io.swagger.annotations.ApiResponse;
8 | import io.swagger.annotations.ApiResponses;
9 | import io.swagger.annotations.Authorization;
10 | import java.util.Arrays;
11 | import java.util.List;
12 | import javax.ws.rs.GET;
13 | import javax.ws.rs.PUT;
14 | import javax.ws.rs.Path;
15 | import javax.ws.rs.PathParam;
16 | import javax.ws.rs.Produces;
17 | import javax.ws.rs.core.MediaType;
18 | import javax.ws.rs.core.Response;
19 |
20 | /**
21 | *
22 | * @author pradeep.chaudhary
23 | */
24 | @Produces(MediaType.APPLICATION_JSON)
25 | @Api(hidden=true, authorizations = {@Authorization(value="api_key")}, tags = {"Resource-V1"})
26 | public class SubResource {
27 |
28 | @GET
29 | @ApiOperation(value="List of users",notes="Get user list")
30 | @ApiResponses(value = {
31 | @ApiResponse(code = 200, message = "Successful operation", response = List.class)
32 | })
33 | public Response getUsers() {
34 | User john = new User();
35 | john.setFirstName("John");
36 | john.setEmail("john@testdomain.com");
37 |
38 | User max = new User();
39 | max.setFirstName("Max");
40 | max.setEmail("max@testdomain.com");
41 |
42 | return Response.ok(Arrays.asList(john, max)).build();
43 | }
44 |
45 | @Path("/{username}")
46 | @GET
47 | @ApiOperation(value="Fetch a user by username")
48 | @ApiResponses(value = {
49 | @ApiResponse(code = 200, message = "Successful operation", response = User.class)
50 | })
51 | public Response getUserByName(@ApiParam(value = "Username of user that needs to be fetched", required = true)
52 | @PathParam("username") String username) {
53 | User max = new User();
54 | max.setFirstName("Max");
55 | max.setEmail("max@testdomain.com");
56 | max.setUsername("max");
57 |
58 | return Response.ok(max).build();
59 | }
60 |
61 | @PUT
62 | @ApiOperation(value="Update User")
63 | @ApiResponses(value = {
64 | @ApiResponse(code = 200, message = "Successful operation")
65 | })
66 | public Response updateUser(@ApiParam(value = "User to be updated", required = true) User user) {
67 | return Response.ok().build();
68 | }
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/SwaggerlessResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import com.wordnik.sample.model.Pet;
4 | import com.wordnik.sample.model.PetName;
5 | import org.springframework.web.bind.annotation.RequestParam;
6 |
7 | import javax.ws.rs.GET;
8 | import javax.ws.rs.Path;
9 | import javax.ws.rs.PathParam;
10 | import javax.ws.rs.QueryParam;
11 |
12 | @Path("/")
13 | public class SwaggerlessResource {
14 |
15 | @GET
16 | @Path("/swaggerless/{petId : [0-9]}")
17 | public Pet getPetByName(@PathParam(value = "name") String name) {
18 | // Just create and return a new pet
19 | Pet pet = new Pet();
20 | pet.setName(new PetName(name));
21 | return pet;
22 | }
23 |
24 | public Pet notAnEndpoint(@PathParam(value = "name") String name) {
25 | // Just create and return a new pet
26 | Pet pet = new Pet();
27 | pet.setName(new PetName(name));
28 | return pet;
29 | }
30 |
31 | @Path("/swaggerless")
32 | public Pet notAnEndpointWithPath(@RequestParam(value = "name") String name) {
33 | // Just create and return a new pet
34 | Pet pet = new Pet();
35 | pet.setName(new PetName(name));
36 | return pet;
37 | }
38 |
39 | @Path("/swaggerless/subresource")
40 | public SwaggerlessSubresource subresourceEndpoint() {
41 | return new SwaggerlessSubresource();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/SwaggerlessSubresource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import com.wordnik.sample.model.Pet;
4 | import com.wordnik.sample.model.PetName;
5 |
6 | import javax.ws.rs.GET;
7 | import javax.ws.rs.Path;
8 | import javax.ws.rs.PathParam;
9 |
10 | public class SwaggerlessSubresource {
11 |
12 | @GET
13 | @Path("/{name}")
14 | public Pet getPetByNameSubresource(@PathParam(value = "name") String name) {
15 | // Just create and return a new pet
16 | Pet pet = new Pet();
17 | pet.setName(new PetName(name));
18 | return pet;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/jaxrs/VendorExtensionsJaxrsReader.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.jaxrs;
2 |
3 | import com.github.kongchen.swagger.docgen.reader.JaxrsReader;
4 | import com.wordnik.sample.TestVendorExtension;
5 | import io.swagger.jaxrs.ext.SwaggerExtension;
6 | import io.swagger.jaxrs.ext.SwaggerExtensions;
7 | import io.swagger.models.Swagger;
8 | import org.apache.maven.plugin.logging.Log;
9 |
10 | import java.util.LinkedList;
11 | import java.util.List;
12 |
13 | public class VendorExtensionsJaxrsReader extends JaxrsReader {
14 |
15 | public VendorExtensionsJaxrsReader(Swagger swagger, Log LOG) {
16 | super(swagger, LOG);
17 |
18 | List extensions = new LinkedList(SwaggerExtensions.getExtensions());
19 | extensions.add(new TestVendorExtension());
20 | SwaggerExtensions.setExtensions(extensions);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/JavaRestResourceUtil.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample;
18 |
19 | import java.text.SimpleDateFormat;
20 | import java.util.Date;
21 |
22 | public class JavaRestResourceUtil {
23 | public int getInt(int minVal, int maxVal, int defaultValue, String inputString) {
24 | int output;
25 | try {
26 | output = Integer.parseInt(inputString);
27 | } catch (Exception e) {
28 | output = defaultValue;
29 | }
30 |
31 | if (output < minVal) {
32 | output = minVal;
33 | }
34 | if (maxVal == -1) {
35 | if (output < minVal) {
36 | output = minVal;
37 | }
38 | } else if (output > maxVal) {
39 | output = maxVal;
40 | }
41 | return output;
42 | }
43 |
44 | public long getLong(long minVal, long maxVal, long defaultValue, String inputString) {
45 | long output;
46 | try {
47 | output = Long.parseLong(inputString);
48 | } catch (Exception e) {
49 | output = defaultValue;
50 | }
51 |
52 | if (output < minVal) {
53 | output = minVal;
54 | }
55 | if (maxVal == -1) {
56 | if (output < minVal) {
57 | output = minVal;
58 | }
59 | } else if (output > maxVal) {
60 | output = maxVal;
61 | }
62 | return output;
63 | }
64 |
65 | public double getDouble(double minVal, double maxVal, double defaultValue, String inputString) {
66 | double output;
67 | try {
68 | output = Double.parseDouble(inputString);
69 | } catch (Exception e) {
70 | output = defaultValue;
71 | }
72 |
73 | if (output < minVal) {
74 | output = minVal;
75 | }
76 | if (maxVal == -1) {
77 | if (output < minVal) {
78 | output = minVal;
79 | }
80 | } else if (output > maxVal) {
81 | output = maxVal;
82 | }
83 | return output;
84 | }
85 |
86 | public boolean getBoolean(boolean defaultValue, String booleanString) {
87 | boolean output;
88 |
89 | // treat "", "YES" as "true"
90 | if ("".equals(booleanString) || "YES".equalsIgnoreCase(booleanString)) {
91 | output = true;
92 | } else if ("NO".equalsIgnoreCase(booleanString)) {
93 | output = false;
94 | } else {
95 | try {
96 | output = Boolean.parseBoolean(booleanString);
97 | } catch (Exception e) {
98 | output = defaultValue;
99 | }
100 | }
101 | return output;
102 | }
103 |
104 | public Date getDate(Date defaultValue, String dateString) {
105 | try {
106 | return new SimpleDateFormat("yyyy-MM-dd").parse(dateString);
107 | } catch (Exception e) {
108 | return defaultValue;
109 | }
110 | }
111 | }
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/TestVendorExtension.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample;
2 |
3 | import io.swagger.jaxrs.ext.AbstractSwaggerExtension;
4 | import io.swagger.jaxrs.ext.SwaggerExtension;
5 | import io.swagger.models.Operation;
6 | import io.swagger.models.Response;
7 |
8 | import java.lang.annotation.ElementType;
9 | import java.lang.annotation.Retention;
10 | import java.lang.annotation.RetentionPolicy;
11 | import java.lang.annotation.Target;
12 | import java.lang.reflect.Method;
13 | import java.util.HashMap;
14 | import java.util.Iterator;
15 | import java.util.Map;
16 |
17 | /**
18 | * @see com.wordnik.jaxrs.VendorExtensionsJaxrsReader
19 | * @see com.wordnik.springmvc.VendorExtensionsSpringMvcReader
20 | */
21 | public class TestVendorExtension extends AbstractSwaggerExtension {
22 |
23 | private static final String RESPONSE_DESCRIPTION = "Some vendor error description";
24 |
25 | private static final String RESPONSE_STATUS_401 = "401";
26 |
27 | @Override
28 | public void decorateOperation(final Operation operation, final Method method, final Iterator chain) {
29 |
30 | final TestVendorAnnotation annotation = method.getAnnotation(TestVendorAnnotation.class);
31 | if (annotation != null) {
32 |
33 | Map map = new HashMap(operation.getResponses());
34 | final Response value = new Response();
35 | value.setDescription(RESPONSE_DESCRIPTION);
36 | map.put(RESPONSE_STATUS_401, value);
37 | operation.setResponses(map);
38 | }
39 |
40 | if (chain.hasNext()) {
41 | chain.next().decorateOperation(operation, method, chain);
42 | }
43 | }
44 |
45 | /**
46 | * Processed by {@link TestVendorExtension}
47 | */
48 | @Target(ElementType.METHOD)
49 | @Retention(RetentionPolicy.RUNTIME)
50 | public @interface TestVendorAnnotation {}
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/VendorExtensionWithoutReader.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample;
2 |
3 | import java.lang.reflect.Method;
4 | import java.util.HashMap;
5 | import java.util.Iterator;
6 | import java.util.Map;
7 |
8 | import com.wordnik.sample.TestVendorExtension.TestVendorAnnotation;
9 |
10 | import io.swagger.jaxrs.ext.AbstractSwaggerExtension;
11 | import io.swagger.jaxrs.ext.SwaggerExtension;
12 | import io.swagger.models.Operation;
13 | import io.swagger.models.Response;
14 |
15 | /**
16 | * Custom swagger extension which will be configured using the <swaggerExtension>
tag.
17 | */
18 | public class VendorExtensionWithoutReader extends AbstractSwaggerExtension {
19 |
20 | private static final String RESPONSE_DESCRIPTION = "Some vendor error description added using swaggerExtension";
21 |
22 | private static final String RESPONSE_STATUS_501 = "501";
23 |
24 | @Override
25 | public void decorateOperation(final Operation operation, final Method method, final Iterator chain) {
26 |
27 | final TestVendorAnnotation annotation = method.getAnnotation(TestVendorAnnotation.class);
28 | if (annotation != null) {
29 |
30 | Map map = new HashMap(operation.getResponses());
31 | final Response value = new Response();
32 | value.setDescription(RESPONSE_DESCRIPTION);
33 | map.put(RESPONSE_STATUS_501, value);
34 | operation.setResponses(map);
35 | }
36 |
37 | if (chain.hasNext()) {
38 | chain.next().decorateOperation(operation, method, chain);
39 | }
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/data/StoreData.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.data;
18 |
19 | import com.wordnik.sample.model.Order;
20 |
21 | import java.util.ArrayList;
22 | import java.util.Date;
23 | import java.util.List;
24 |
25 | public class StoreData {
26 | static List orders = new ArrayList();
27 |
28 | static {
29 | orders.add(createOrder(1, 1, 2, new Date(), "placed"));
30 | orders.add(createOrder(2, 1, 2, new Date(), "delivered"));
31 | orders.add(createOrder(3, 2, 2, new Date(), "placed"));
32 | orders.add(createOrder(4, 2, 2, new Date(), "delivered"));
33 | orders.add(createOrder(5, 3, 2, new Date(), "placed"));
34 | orders.add(createOrder(11, 3, 2, new Date(), "placed"));
35 | orders.add(createOrder(12, 3, 2, new Date(), "placed"));
36 | orders.add(createOrder(13, 3, 2, new Date(), "placed"));
37 | orders.add(createOrder(14, 3, 2, new Date(), "placed"));
38 | orders.add(createOrder(15, 3, 2, new Date(), "placed"));
39 | }
40 |
41 | public Order findOrderById(long orderId) {
42 | for (Order order : orders) {
43 | if (order.getId() == orderId) {
44 | return order;
45 | }
46 | }
47 | return null;
48 | }
49 |
50 | public Order placeOrder(Order order) {
51 | if (!orders.isEmpty()) {
52 | for (int i = orders.size() - 1; i >= 0; i--) {
53 | if (orders.get(i).getId() == order.getId()) {
54 | orders.remove(i);
55 | }
56 | }
57 | }
58 | orders.add(order);
59 | return order;
60 | }
61 |
62 | public void deleteOrder(long orderId) {
63 | if (!orders.isEmpty()) {
64 | for (int i = orders.size() - 1; i >= 0; i--) {
65 | if (orders.get(i).getId() == orderId) {
66 | orders.remove(i);
67 | }
68 | }
69 | }
70 | }
71 |
72 | private static Order createOrder(long id, long petId, int quantity, Date shipDate, String status) {
73 | Order order = new Order();
74 | order.setId(id);
75 | order.setPetId(petId);
76 | order.setQuantity(quantity);
77 | order.setShipDate(shipDate);
78 | order.setStatus(status);
79 | return order;
80 | }
81 | }
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/data/UserData.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.data;
18 |
19 | import com.wordnik.sample.model.User;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | public class UserData {
25 | static List users = new ArrayList();
26 |
27 | static {
28 | users.add(createUser(1, "user1", "first name 1", "last name 1",
29 | "email1@test.com", "123-456-7890", 1));
30 | users.add(createUser(2, "user2", "first name 2", "last name 2",
31 | "email2@test.com", "123-456-7890", 2));
32 | users.add(createUser(3, "user3", "first name 3", "last name 3",
33 | "email3@test.com", "123-456-7890", 3));
34 | users.add(createUser(4, "user4", "first name 4", "last name 4",
35 | "email4@test.com", "123-456-7890", 1));
36 | users.add(createUser(5, "user5", "first name 5", "last name 5",
37 | "email5@test.com", "123-456-7890", 2));
38 | users.add(createUser(6, "user6", "first name 6", "last name 6",
39 | "email6@test.com", "123-456-7890", 3));
40 | users.add(createUser(7, "user7", "first name 7", "last name 7",
41 | "email7@test.com", "123-456-7890", 1));
42 | users.add(createUser(8, "user8", "first name 8", "last name 8",
43 | "email8@test.com", "123-456-7890", 2));
44 | users.add(createUser(9, "user9", "first name 9", "last name 9",
45 | "email9@test.com", "123-456-7890", 3));
46 | users.add(createUser(10, "user10", "first name 10", "last name 10",
47 | "email10@test.com", "123-456-7890", 1));
48 | users.add(createUser(11, "user?10", "first name ?10", "last name ?10",
49 | "email101@test.com", "123-456-7890", 1));
50 |
51 | }
52 |
53 | public User findUserByName(String username) {
54 | for (User user : users) {
55 | if (user.getUsername().equals(username)) {
56 | return user;
57 | }
58 | }
59 | return null;
60 | }
61 |
62 | public void addUser(User user) {
63 | if (!users.isEmpty()) {
64 | for (int i = users.size() - 1; i >= 0; i--) {
65 | if (users.get(i).getUsername().equals(user.getUsername())) {
66 | users.remove(i);
67 | }
68 | }
69 | }
70 | users.add(user);
71 | }
72 |
73 | public void removeUser(String username) {
74 | if (!users.isEmpty()) {
75 | for (int i = users.size() - 1; i >= 0; i--) {
76 | if (users.get(i).getUsername().equals(username)) {
77 | users.remove(i);
78 | }
79 | }
80 | }
81 | }
82 |
83 | private static User createUser(long id, String username, String firstName,
84 | String lastName, String email, String phone, int userStatus) {
85 | User user = new User();
86 | user.setId(id);
87 | user.setUsername(username);
88 | user.setFirstName(firstName);
89 | user.setLastName(lastName);
90 | user.setEmail(email);
91 | user.setPassword("XXXXXXXXXXX");
92 | user.setPhone(phone);
93 | user.setUserStatus(userStatus);
94 | return user;
95 | }
96 | }
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/exception/ApiException.java:
--------------------------------------------------------------------------------
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 com.wordnik.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 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/exception/BadRequestException.java:
--------------------------------------------------------------------------------
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 com.wordnik.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 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/exception/NotFoundException.java:
--------------------------------------------------------------------------------
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 com.wordnik.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 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/ApiResponse.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import javax.xml.bind.annotation.XmlTransient;
20 |
21 | @javax.xml.bind.annotation.XmlRootElement
22 | public class ApiResponse {
23 | public static final int ERROR = 1;
24 | public static final int WARNING = 2;
25 | public static final int INFO = 3;
26 | public static final int OK = 4;
27 | public static final int TOO_BUSY = 5;
28 |
29 | int code;
30 | String type;
31 | String message;
32 |
33 | public ApiResponse() {
34 | }
35 |
36 | public ApiResponse(int code, String message) {
37 | this.code = code;
38 | switch (code) {
39 | case ERROR:
40 | setType("error");
41 | break;
42 | case WARNING:
43 | setType("warning");
44 | break;
45 | case INFO:
46 | setType("info");
47 | break;
48 | case OK:
49 | setType("ok");
50 | break;
51 | case TOO_BUSY:
52 | setType("too busy");
53 | break;
54 | default:
55 | setType("unknown");
56 | break;
57 | }
58 | this.message = message;
59 | }
60 |
61 | @XmlTransient
62 | public int getCode() {
63 | return code;
64 | }
65 |
66 | public void setCode(int code) {
67 | this.code = code;
68 | }
69 |
70 | public String getType() {
71 | return type;
72 | }
73 |
74 | public void setType(String type) {
75 | this.type = type;
76 | }
77 |
78 | public String getMessage() {
79 | return message;
80 | }
81 |
82 | public void setMessage(String message) {
83 | this.message = message;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/Category.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import javax.xml.bind.annotation.XmlElement;
20 | import javax.xml.bind.annotation.XmlRootElement;
21 |
22 | @XmlRootElement(name = "Category", namespace = "http://com.wordnik/sample/model/category")
23 | public class Category {
24 | private long id;
25 | private String name;
26 |
27 | @XmlElement(name = "id", namespace = "http://com.wordnik/sample/model/category")
28 | public long getId() {
29 | return id;
30 | }
31 |
32 | public void setId(long id) {
33 | this.id = id;
34 | }
35 |
36 | @XmlElement(name = "name", namespace = "http://com.wordnik/sample/model/category")
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/ListItem.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample.model;
2 |
3 | import javax.xml.bind.annotation.XmlElement;
4 | import javax.xml.bind.annotation.XmlRootElement;
5 |
6 | @XmlRootElement(name = "ListItem")
7 | public class ListItem {
8 | private long id;
9 |
10 | @XmlElement(name = "id")
11 | public long getId() {
12 | return id;
13 | }
14 |
15 | public void setId(long id) {
16 | this.id = id;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/Order.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import com.google.common.base.Optional; // Must be Google Guava Optional, because we run Java 6.
20 | import io.swagger.annotations.ApiModelProperty;
21 |
22 | import javax.xml.bind.annotation.XmlElement;
23 | import javax.xml.bind.annotation.XmlRootElement;
24 | import java.util.Date;
25 |
26 | @XmlRootElement(name = "Order")
27 | public class Order {
28 | private long id;
29 | private long petId;
30 | private int quantity;
31 | private Date shipDate;
32 | private String status;
33 | private boolean complete;
34 | @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
35 | private Optional optionalStatus;
36 |
37 | private String internalThing;
38 | private String anotherInternalThing;
39 |
40 | @XmlElement(name = "id")
41 | public long getId() {
42 | return id;
43 | }
44 |
45 | public void setId(long id) {
46 | this.id = id;
47 | }
48 |
49 | public boolean isComplete() {
50 | return complete;
51 | }
52 |
53 | public void setComplete(boolean complete) {
54 | this.complete = complete;
55 | }
56 |
57 | @XmlElement(name = "petId")
58 | public long getPetId() {
59 | return petId;
60 | }
61 |
62 | public void setPetId(long petId) {
63 | this.petId = petId;
64 | }
65 |
66 | @XmlElement(name = "quantity")
67 | public int getQuantity() {
68 | return quantity;
69 | }
70 |
71 | public void setQuantity(int quantity) {
72 | this.quantity = quantity;
73 | }
74 |
75 | @XmlElement(name = "status")
76 | @ApiModelProperty(value = "Order Status", allowableValues = "placed, approved, delivered")
77 | public String getStatus() {
78 | return status;
79 | }
80 |
81 | public void setStatus(String status) {
82 | this.status = status;
83 | }
84 |
85 | @XmlElement(name = "shipDate")
86 | public Date getShipDate() {
87 | return shipDate;
88 | }
89 |
90 | public void setShipDate(Date shipDate) {
91 | this.shipDate = shipDate;
92 | }
93 |
94 | @XmlElement(name = "optionalStatus")
95 | public Optional getOptionalStatus() { return optionalStatus; }
96 |
97 | public void setOptionalStatus(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional optionalStatus) { this.optionalStatus = optionalStatus; }
98 |
99 | @ApiModelProperty(name = "internalThing", access = "secret-property")
100 | public String getInternalThing() {
101 | return internalThing;
102 | }
103 |
104 | @ApiModelProperty(name = "anotherInternalThing", access = "another-secret-property")
105 | public String getAnotherInternalThing() {
106 | return anotherInternalThing;
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/PaginationHelper.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample.model;
2 |
3 | import io.swagger.annotations.ApiParam;
4 |
5 | public class PaginationHelper {
6 | private Integer limit;
7 | private Integer offset;
8 |
9 | public PaginationHelper() {
10 | }
11 |
12 | public Integer getLimit() {
13 | return limit;
14 | }
15 |
16 | @ApiParam(value = "The pagination limit", name = "limit")
17 | public void setLimit(Integer limit) {
18 | this.limit = limit;
19 | }
20 |
21 | public Integer getOffset() {
22 | return offset;
23 | }
24 |
25 | @ApiParam(value = "The pagination offset", name = "offset")
26 | public void setOffset(Integer offset) {
27 | this.offset = offset;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/Pet.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import io.swagger.annotations.ApiModelProperty;
20 |
21 | import javax.xml.bind.annotation.XmlElement;
22 | import javax.xml.bind.annotation.XmlElementWrapper;
23 | import javax.xml.bind.annotation.XmlRootElement;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | @XmlRootElement(name = "Pet")
28 | public class Pet {
29 | private PetId id;
30 | private Category category;
31 | private PetName name;
32 | private List photoUrls = new ArrayList();
33 | private List tags = new ArrayList();
34 | private String status;
35 |
36 | @XmlElement(name = "id")
37 | public PetId getId() {
38 | return id;
39 | }
40 |
41 | public void setId(PetId id) {
42 | this.id = id;
43 | }
44 |
45 | @XmlElement(name = "category")
46 | public Category getCategory() {
47 | return category;
48 | }
49 |
50 | public void setCategory(Category category) {
51 | this.category = category;
52 | }
53 |
54 | @XmlElement(name = "name")
55 | @ApiModelProperty(name = "name", example = "doggie", required = true, access = "exclude-when-jev-option-set")
56 | public PetName getName() {
57 | return name;
58 | }
59 |
60 | public void setName(PetName name) {
61 | this.name = name;
62 | }
63 |
64 | @XmlElementWrapper(name = "photoUrls")
65 | @XmlElement(name = "photoUrl", required = true)
66 | public List getPhotoUrls() {
67 | return photoUrls;
68 | }
69 |
70 | public void setPhotoUrls(List photoUrls) {
71 | this.photoUrls = photoUrls;
72 | }
73 |
74 | @XmlElementWrapper(name = "tags")
75 | @XmlElement(name = "tag")
76 | public List getTags() {
77 | return tags;
78 | }
79 |
80 | public void setTags(List tags) {
81 | this.tags = tags;
82 | }
83 |
84 | @XmlElement(name = "status")
85 | @ApiModelProperty(value = "pet status in the store", allowableValues = "available,pending,sold")
86 | public String getStatus() {
87 | return status;
88 | }
89 |
90 | public void setStatus(String status) {
91 | this.status = status;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/PetId.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample.model;
2 |
3 | /**
4 | * @author chekong on 15/5/19.
5 | */
6 | public class PetId {
7 | private final long id;
8 |
9 | public PetId(long id) {
10 | this.id = id;
11 | }
12 |
13 | public long value() {
14 | return id;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/PetName.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample.model;
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator;
4 | import com.fasterxml.jackson.annotation.JsonProperty;
5 |
6 | /**
7 | * @author chekong on 15/5/19.
8 | */
9 | public class PetName {
10 | private final String name;
11 |
12 | @JsonCreator
13 | public static PetName fromString(@JsonProperty("name") String name) {
14 |
15 | return new PetName(name);
16 | }
17 |
18 | public PetName(String name) {
19 | this.name = name;
20 | }
21 |
22 | @Override
23 | public String toString() {
24 | return name;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/PetStatus.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.sample.model;
2 |
3 | /**
4 | * @author chekong on 15/5/12.
5 | */
6 | public enum PetStatus {
7 | AVAILABLE,
8 | PENDING,
9 | SOLD
10 | }
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/Tag.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import javax.xml.bind.annotation.XmlElement;
20 | import javax.xml.bind.annotation.XmlRootElement;
21 |
22 | @XmlRootElement(name = "Tag")
23 | public class Tag {
24 | private long id;
25 | private String name;
26 |
27 | @XmlElement(name = "id")
28 | public long getId() {
29 | return id;
30 | }
31 |
32 | public void setId(long id) {
33 | this.id = id;
34 | }
35 |
36 | @XmlElement(name = "name")
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 | }
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/User.java:
--------------------------------------------------------------------------------
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 com.wordnik.sample.model;
18 |
19 | import io.swagger.annotations.ApiModelProperty;
20 | import io.swagger.annotations.Extension;
21 | import io.swagger.annotations.ExtensionProperty;
22 |
23 | import javax.xml.bind.annotation.XmlElement;
24 | import javax.xml.bind.annotation.XmlRootElement;
25 |
26 | @XmlRootElement(name = "User")
27 | public class User {
28 | private long id;
29 | private String username;
30 | private String firstName;
31 | private String lastName;
32 | private String nickName;
33 | private String email;
34 | private String password;
35 | private String phone;
36 | private int userStatus;
37 |
38 | @XmlElement(name = "id")
39 | public long getId() {
40 | return id;
41 | }
42 |
43 | public void setId(long id) {
44 | this.id = id;
45 | }
46 |
47 | @XmlElement(name = "firstName")
48 | public String getFirstName() {
49 | return firstName;
50 | }
51 |
52 | public void setFirstName(String firstName) {
53 | this.firstName = firstName;
54 | }
55 |
56 | @XmlElement(name = "username")
57 | public String getUsername() {
58 | return username;
59 | }
60 |
61 | public void setUsername(String username) {
62 | this.username = username;
63 | }
64 |
65 | @XmlElement(name = "lastName")
66 | public String getLastName() {
67 | return lastName;
68 | }
69 |
70 | public void setLastName(String lastName) {
71 | this.lastName = lastName;
72 | }
73 |
74 | @XmlElement(name = "nickName")
75 | @ApiModelProperty(name = "nickName", example = "\"Bob\"", access = "exclude-when-jev-option-not-set")
76 | public String getNickName() {
77 | return nickName;
78 | }
79 |
80 | public void setNickName(String nickName) {
81 | this.nickName = nickName;
82 | }
83 |
84 | @XmlElement(name = "email")
85 | public String getEmail() {
86 | return email;
87 | }
88 |
89 | public void setEmail(String email) {
90 | this.email = email;
91 | }
92 |
93 | @XmlElement(name = "password")
94 | public String getPassword() {
95 | return password;
96 | }
97 |
98 | public void setPassword(String password) {
99 | this.password = password;
100 | }
101 |
102 | @XmlElement(name = "phone")
103 | @ApiModelProperty(name = "phone", extensions = @Extension(properties = @ExtensionProperty(name = "test", value = "value")))
104 | public String getPhone() {
105 | return phone;
106 | }
107 |
108 | public void setPhone(String phone) {
109 | this.phone = phone;
110 | }
111 |
112 | @XmlElement(name = "userStatus")
113 | @ApiModelProperty(value = "User Status", allowableValues = "1-registered,2-active,3-closed", example = "2")
114 | public int getUserStatus() {
115 | return userStatus;
116 | }
117 |
118 | public void setUserStatus(int userStatus) {
119 | this.userStatus = userStatus;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/sample/model/package-info.java:
--------------------------------------------------------------------------------
1 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://com.wordnik/sample/model", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
2 | package com.wordnik.sample.model;
3 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/spring/skipinherited/MyResourceBean.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.spring.skipinherited;
2 |
3 | import java.util.List;
4 |
5 | import com.wordnik.sample.model.ListItem;
6 |
7 | public class MyResourceBean implements MyResourceSI {
8 |
9 | @Override
10 | public List getListOfItems(String param) {
11 | return null;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/spring/skipinherited/MyResourceSI.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.spring.skipinherited;
2 |
3 | import com.wordnik.sample.model.ListItem;
4 | import io.swagger.annotations.Api;
5 | import io.swagger.annotations.ApiOperation;
6 | import io.swagger.annotations.ApiParam;
7 |
8 | import org.springframework.web.bind.annotation.RequestHeader;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestMethod;
11 |
12 | import java.util.List;
13 |
14 | @Api(description = "Operations about pets")
15 | @RequestMapping(value = "/myResourceSkipInherited", produces = {"application/json", "application/xml"})
16 | public interface MyResourceSI {
17 |
18 | @RequestMapping(method = RequestMethod.GET, value = "list")
19 | @ApiOperation(value = "Get a list of items",
20 | notes = "This is a contrived example"
21 | )
22 | public List getListOfItems(
23 | @RequestHeader(name = "X-Simple-Param", required = true)
24 | @ApiParam(name = "X-Simple-Param",
25 | value = "The Simple Param", required = true,
26 | example = "ABC45678901234567") String param);
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/CustomSpringMvcReader.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import com.github.kongchen.swagger.docgen.GenerateException;
4 | import com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader;
5 | import com.github.kongchen.swagger.docgen.spring.SpringResource;
6 | import io.swagger.models.Swagger;
7 |
8 | import java.util.Map;
9 | import java.util.Set;
10 | import org.apache.maven.plugin.logging.Log;
11 |
12 | /**
13 | * @author Igor Gursky
14 | * 11.12.2015.
15 | */
16 | public class CustomSpringMvcReader extends VendorExtensionsSpringMvcReader {
17 | public CustomSpringMvcReader(Swagger swagger, Log log) {
18 | super(swagger, log);
19 | }
20 |
21 | @Override
22 | public Swagger read(Set> classes) throws GenerateException {
23 | Map resourceMap = generateResourceMap(classes);
24 | for (String str : resourceMap.keySet()) {
25 | SpringResource resource = resourceMap.get(str);
26 | read(resource);
27 | }
28 | swagger.getInfo().setDescription("Processed with CustomSpringMvcReader");
29 | return swagger;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/EchoResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 | import org.springframework.web.bind.annotation.*;
6 |
7 | @Api(value = "/echo", description = "Set of simple endpoints that return whatever value you pass in")
8 | @RequestMapping(value = "/echo", produces = {"application/json", "application/xml"})
9 | public class EchoResource {
10 |
11 | // Tests for @PathVariable
12 | @RequestMapping(value = "/pathVariableExpectParameterName/{parameterName}", method = RequestMethod.GET, produces = "application/json")
13 | @ApiOperation(value = "")
14 | public String pathVariableExpectParameterName(@PathVariable String parameterName) {
15 | return parameterName;
16 | }
17 |
18 | @RequestMapping(value = "/pathVariableExpectVariableName/{parameterName}", method = RequestMethod.GET, produces = "application/json")
19 | @ApiOperation(value = "")
20 | public String pathVariableExpectVariableName(@PathVariable(name = "pathVariableName") String parameterName) {
21 | return parameterName;
22 | }
23 |
24 | @RequestMapping(value = "/pathVariableExpectVariableValue/{parameterName}", method = RequestMethod.GET, produces = "application/json")
25 | @ApiOperation(value = "")
26 | public String pathVariableExpectVariableValue(@PathVariable(value = "pathVariableValue") String parameterName) {
27 | return parameterName;
28 | }
29 |
30 | // Tests for @RequestParam
31 | @RequestMapping(value = "/requestParamExpectParameterName", method = RequestMethod.GET, produces = "application/json")
32 | @ApiOperation(value = "")
33 | public String requestParamExpectParameterName(@RequestParam String parameterName) {
34 | return parameterName;
35 | }
36 |
37 | @RequestMapping(value = "/requestParamExpectParamName", method = RequestMethod.GET, produces = "application/json")
38 | @ApiOperation(value = "")
39 | public String requestParamExpectParamName(@RequestParam(name = "requestParamName") String parameterName) {
40 | return parameterName;
41 | }
42 |
43 | @RequestMapping(value = "/requestParamExpectParamValue", method = RequestMethod.GET, produces = "application/json")
44 | @ApiOperation(value = "")
45 | public String requestParamExpectParamValue(@RequestParam(value = "requestParamValue") String parameterName) {
46 | return parameterName;
47 | }
48 |
49 | // Tests for @RequestHeader
50 | @RequestMapping(value = "/requestHeaderExpectParameterName", method = RequestMethod.GET, produces = "application/json")
51 | @ApiOperation(value = "")
52 | public String requestHeaderExpectParameterName(@RequestHeader String parameterName) {
53 | return parameterName;
54 | }
55 |
56 | @RequestMapping(value = "/requestHeaderExpectHeaderName", method = RequestMethod.GET, produces = "application/json")
57 | @ApiOperation(value = "")
58 | public String requestHeaderExpectHeaderName(@RequestHeader(name = "requestHeaderName") String parameterName) {
59 | return parameterName;
60 | }
61 |
62 | @RequestMapping(value = "/requestHeaderExpectHeaderValue", method = RequestMethod.GET, produces = "application/json")
63 | @ApiOperation(value = "")
64 | public String requestHeaderExpectHeaderValue(@RequestHeader(value = "requestHeaderValue") String parameterName) {
65 | return parameterName;
66 | }
67 |
68 | // Tests for @CookieValue
69 | @RequestMapping(value = "/cookieValueExpectParameterName", method = RequestMethod.GET, produces = "application/json")
70 | @ApiOperation(value = "")
71 | public String cookieValueExpectParameterName(@CookieValue String parameterName) {
72 | return parameterName;
73 | }
74 |
75 | @RequestMapping(value = "/cookieValueExpectCookieName", method = RequestMethod.GET, produces = "application/json")
76 | @ApiOperation(value = "")
77 | public String cookieValueExpectCookieName(@CookieValue(name = "cookieValueName") String parameterName) {
78 | return parameterName;
79 | }
80 |
81 | @RequestMapping(value = "/cookieValueExpectCookieValue", method = RequestMethod.GET, produces = "application/json")
82 | @ApiOperation(value = "")
83 | public String cookieValueExpectCookieValue(@CookieValue(value = "cookieValueValue") String parameterName) {
84 | return parameterName;
85 | }
86 |
87 | // Tests for @RequestPart
88 | @RequestMapping(value = "/requestPartExpectParameterName", method = RequestMethod.GET, produces = "application/json")
89 | @ApiOperation(value = "")
90 | public String requestPartExpectParameterName(@RequestPart String parameterName) {
91 | return parameterName;
92 | }
93 |
94 | @RequestMapping(value = "/requestPartExpectPartName", method = RequestMethod.GET, produces = "application/json")
95 | @ApiOperation(value = "")
96 | public String requestPartExpectPartName(@RequestPart(name = "requestPartName") String parameterName) {
97 | return parameterName;
98 | }
99 |
100 | @RequestMapping(value = "/requestPartExpectPartValue", method = RequestMethod.GET, produces = "application/json")
101 | @ApiOperation(value = "")
102 | public String requestPartExpectPartValue(@RequestPart(value = "requestPartValue") String parameterName) {
103 | return parameterName;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/EmptyRootPathResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 |
10 | /**
11 | * @author carlosjgp
12 | */
13 | @RequestMapping
14 | @Api
15 | public class EmptyRootPathResource {
16 | @ApiOperation(value = "testingEmptyRootPathResource")
17 | @RequestMapping(value="/testingEmptyRootPathResource",method = RequestMethod.GET)
18 | public ResponseEntity testingEmptyRootPathResource() {
19 | return new ResponseEntity("testingEmptyRootPathResource", HttpStatus.OK);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/KotlinController.kt:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc
2 |
3 | import org.springframework.web.bind.annotation.GetMapping
4 | import org.springframework.web.bind.annotation.RequestParam
5 | import org.springframework.web.bind.annotation.RestController
6 |
7 | @RestController
8 | class KotlinController {
9 |
10 | @GetMapping("/getWithParam")
11 | fun getWithParam(@RequestParam optionalParam: Boolean = false) {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/MyResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import com.wordnik.sample.model.ListItem;
4 | import io.swagger.annotations.Api;
5 | import io.swagger.annotations.ApiOperation;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 |
9 | import java.util.List;
10 |
11 | @Api(description = "Operations about pets")
12 | @RequestMapping(value = "/myResourceImpl", produces = {"application/json", "application/xml"})
13 | public interface MyResource {
14 |
15 | //contrived example test case for swagger-maven-plugin issue #505
16 | @RequestMapping(method = RequestMethod.GET, value = "list")
17 | @ApiOperation(value = "Get a list of items",
18 | notes = "This is a contrived example"
19 | )
20 | public abstract List getListOfItems();
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/MyResourceImpl.java:
--------------------------------------------------------------------------------
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 com.wordnik.springmvc;
18 |
19 | import com.wordnik.sample.model.ListItem;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | public class MyResourceImpl implements MyResource {
25 |
26 | //contrived example test case for swagger-maven-plugin issue #505
27 | /* (non-Javadoc)
28 | * @see com.wordnik.springmvc.MyResource#getListOfItems()
29 | */
30 | @Override
31 | public List getListOfItems() {
32 | return new ArrayList();
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/RootPathResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import io.swagger.annotations.Api;
4 | import io.swagger.annotations.ApiOperation;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 |
10 | /**
11 | * @author andrewb
12 | */
13 | @RequestMapping(value = "/")
14 | @Api(value = "/")
15 | public class RootPathResource {
16 | @ApiOperation(value = "testingRootPathResource")
17 | @RequestMapping(method = RequestMethod.GET)
18 | public ResponseEntity testingRootPathResource() {
19 | return new ResponseEntity("testingRootPathResource", HttpStatus.OK);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/SwaggerlessResource.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import com.wordnik.sample.model.Pet;
4 | import com.wordnik.sample.model.PetName;
5 | import org.springframework.web.bind.annotation.PathVariable;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @RestController
11 | public class SwaggerlessResource {
12 |
13 | @RequestMapping(value = "/swaggerless/{petId}", method = RequestMethod.GET)
14 | public Pet getPetByName(@PathVariable(value = "name") String name) {
15 | // Just create and return a new pet
16 | Pet pet = new Pet();
17 | pet.setName(new PetName(name));
18 | return pet;
19 | }
20 |
21 | public Pet notAnEndpoint(@PathVariable(value = "name") String name) {
22 | // Just create and return a new pet
23 | Pet pet = new Pet();
24 | pet.setName(new PetName(name));
25 | return pet;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/UpdatePetRequest.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import io.swagger.annotations.ApiParam;
4 | import org.springframework.web.bind.annotation.PathVariable;
5 |
6 | public class UpdatePetRequest {
7 | private String petId;
8 | private String name;
9 | private String status;
10 |
11 | public String getName() {
12 | return name;
13 | }
14 |
15 | @ApiParam(value = "ID of pet that needs to be updated", required = true)
16 | public void setPetId(@PathVariable("petId") String petId) {
17 | this.petId = petId;
18 | }
19 |
20 | public String getStatus() {
21 | return status;
22 | }
23 |
24 | @ApiParam(value = "Updated name of the pet", required = false)
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 |
29 | public String getPetId() {
30 | return petId;
31 | }
32 |
33 | @ApiParam(value = "Updated status of the pet", required = false)
34 | public void setStatus(String status) {
35 | this.status = status;
36 | }
37 |
38 | public UpdatePetRequest() {
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/springmvc/VendorExtensionsSpringMvcReader.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.springmvc;
2 |
3 | import com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader;
4 | import com.wordnik.sample.TestVendorExtension;
5 | import io.swagger.jaxrs.ext.SwaggerExtension;
6 | import io.swagger.jaxrs.ext.SwaggerExtensions;
7 | import io.swagger.models.Swagger;
8 | import org.apache.maven.plugin.logging.Log;
9 |
10 | import java.util.LinkedList;
11 | import java.util.List;
12 |
13 | public class VendorExtensionsSpringMvcReader extends SpringMvcApiReader {
14 |
15 | public VendorExtensionsSpringMvcReader(Swagger swagger, Log log) {
16 | super(swagger, log);
17 |
18 | List extensions = new LinkedList(SwaggerExtensions.getExtensions());
19 | extensions.add(new TestVendorExtension());
20 | SwaggerExtensions.setExtensions(extensions);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/stringwrapper/SimpleStringWrapper.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.stringwrapper;
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator;
4 |
5 | public class SimpleStringWrapper {
6 |
7 | private String value;
8 |
9 | public SimpleStringWrapper() {
10 | }
11 |
12 | @JsonCreator
13 | public SimpleStringWrapper(String value) {
14 | this.value = value;
15 | }
16 |
17 | public String getValue() {
18 | return value;
19 | }
20 |
21 | public void setValue(String value) {
22 | this.value = value;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/com/wordnik/stringwrapper/SimpleWrappersService.java:
--------------------------------------------------------------------------------
1 | package com.wordnik.stringwrapper;
2 |
3 | import org.springframework.web.bind.annotation.CookieValue;
4 | import org.springframework.web.bind.annotation.PathVariable;
5 | import org.springframework.web.bind.annotation.RequestBody;
6 | import org.springframework.web.bind.annotation.RequestHeader;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 | import org.springframework.web.bind.annotation.RequestParam;
10 |
11 | import io.swagger.annotations.Api;
12 | import io.swagger.annotations.ApiParam;
13 |
14 | @Api
15 | @RequestMapping(value = "/wrappers", produces = {"application/json"})
16 | public class SimpleWrappersService {
17 |
18 | @RequestMapping(method = RequestMethod.POST, value = "/body")
19 | public String stringWrapperBody(
20 | @RequestBody @ApiParam(value = "Must be passed as JSON object", required = true) SimpleStringWrapper wrapper) {
21 | return null;
22 | }
23 |
24 | @RequestMapping(method = RequestMethod.GET, value = "/param")
25 | public String stringWrapperParam(
26 | @RequestParam @ApiParam(value = "Must be passed as String", required = true) SimpleStringWrapper wrapper) {
27 | return null;
28 | }
29 |
30 | @RequestMapping(method = RequestMethod.GET, value = "/header")
31 | public String stringWrapperHeader(
32 | @RequestHeader @ApiParam(value = "Must be passed as String", required = true) SimpleStringWrapper wrapper) {
33 | return null;
34 | }
35 |
36 | @RequestMapping(method = RequestMethod.GET, value = "/path/{wrapper}")
37 | public String stringWrapperPath(
38 | @PathVariable @ApiParam(value = "Must be passed as String", required = true) SimpleStringWrapper wrapper) {
39 | return null;
40 | }
41 |
42 | @RequestMapping(method = RequestMethod.GET, value = "/cookie")
43 | public String stringWrapperCookie(
44 | @CookieValue @ApiParam(value = "Must be passed as String", required = true) SimpleStringWrapper wrapper) {
45 | return null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/resources/com/github/kongchen/swagger/docgen/descriptionFile.txt:
--------------------------------------------------------------------------------
1 | Description file content
2 |
--------------------------------------------------------------------------------
/src/test/resources/com/github/kongchen/swagger/docgen/mavenplugin/securityDefinition.json:
--------------------------------------------------------------------------------
1 | {
2 | "api_key": {
3 | "type": "apiKey",
4 | "name": "api_key_name",
5 | "in": "header"
6 | },
7 | "api_key_empty_name": {
8 | "type": "apiKey",
9 | "in": "header"
10 | },
11 | "petstore_auth": {
12 | "type": "oauth2",
13 | "authorizationUrl": "http://swagger.io/api/oauth/dialog",
14 | "flow": "implicit",
15 | "scopes": {
16 | "write:pets": "modify pets in your account",
17 | "read:pets": "read your pets"
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/resources/expectedOutput/swagger-common-parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger" : "2.0",
3 | "paths" : {
4 | "/apath" : {
5 | "get" : {
6 | "operationId" : "getOperation",
7 | "parameters" : [ {
8 | "$ref" : "#/parameters/headerParam"
9 | }, {
10 | "$ref" : "#/parameters/queryParam"
11 | } ],
12 | "responses" : {
13 | "default" : {
14 | "description" : "successful operation"
15 | }
16 | }
17 | }
18 | }
19 | },
20 | "parameters" : {
21 | "headerParam" : {
22 | "name" : "headerParam",
23 | "in" : "header",
24 | "required" : false,
25 | "type" : "string"
26 | },
27 | "queryParam" : {
28 | "name" : "queryParam",
29 | "in" : "query",
30 | "required" : false,
31 | "type" : "string"
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/test/resources/expectedOutput/swagger-spring-skip-inherited.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger" : "2.0",
3 | "info" : {
4 | "description" : "This is a sample.",
5 | "version" : "v1",
6 | "title" : "Swagger Maven Plugin Sample",
7 | "termsOfService" : "http://www.github.com/kongchen/swagger-maven-plugin",
8 | "contact" : {
9 | "name" : "Kong Chen",
10 | "url" : "http://kongch.com",
11 | "email" : "kongchen@gmail.com"
12 | },
13 | "license" : {
14 | "name" : "Apache 2.0",
15 | "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
16 | }
17 | },
18 | "host" : "www.example.com:8080",
19 | "basePath" : "/api",
20 | "schemes" : [ "http", "https" ],
21 | "paths" : {
22 | "/myResourceSkipInherited/list" : {
23 | "get" : {
24 | "summary" : "Get a list of items",
25 | "description" : "This is a contrived example",
26 | "operationId" : "getListOfItems",
27 | "produces" : [ "application/json", "application/xml" ],
28 | "parameters" : [ {
29 | "name" : "X-Simple-Param",
30 | "in" : "header",
31 | "description" : "The Simple Param",
32 | "required" : true,
33 | "type" : "string",
34 | "x-example" : "ABC45678901234567"
35 | } ],
36 | "responses" : {
37 | "200" : {
38 | "description" : "successful operation",
39 | "schema" : {
40 | "type" : "array",
41 | "items" : {
42 | "$ref" : "#/definitions/ListItem"
43 | }
44 | }
45 | }
46 | }
47 | }
48 | }
49 | },
50 | "securityDefinitions" : {
51 | "api_key" : {
52 | "type" : "apiKey",
53 | "name" : "api_key",
54 | "in" : "header"
55 | },
56 | "basicAuth" : {
57 | "type" : "basic"
58 | },
59 | "petstore_auth" : {
60 | "type" : "oauth2",
61 | "authorizationUrl" : "http://swagger.io/api/oauth/dialog",
62 | "flow" : "implicit",
63 | "scopes" : {
64 | "write:pets" : "modify pets in your account",
65 | "read:pets" : "read your pets"
66 | }
67 | }
68 | },
69 | "definitions" : {
70 | "ListItem" : {
71 | "type" : "object",
72 | "properties" : {
73 | "id" : {
74 | "type" : "integer",
75 | "format" : "int64"
76 | }
77 | },
78 | "xml" : {
79 | "name" : "ListItem",
80 | "namespace" : "http://com.wordnik/sample/model"
81 | }
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/src/test/resources/expectedOutput/swagger-spring-string-wrapper-model.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger" : "2.0",
3 | "info" : {
4 | "description" : "This is a sample.",
5 | "version" : "v1",
6 | "title" : "Swagger Maven Plugin Sample",
7 | "termsOfService" : "http://www.github.com/kongchen/swagger-maven-plugin",
8 | "contact" : {
9 | "name" : "Kong Chen",
10 | "url" : "http://kongch.com",
11 | "email" : "kongchen@gmail.com"
12 | },
13 | "license" : {
14 | "name" : "Apache 2.0",
15 | "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
16 | }
17 | },
18 | "host" : "www.example.com:8080",
19 | "basePath" : "/api",
20 | "schemes" : [ "http", "https" ],
21 | "paths" : {
22 | "/wrappers/body" : {
23 | "post" : {
24 | "operationId" : "stringWrapperBody",
25 | "produces" : [ "application/json" ],
26 | "parameters" : [ {
27 | "in" : "body",
28 | "name" : "body",
29 | "description" : "Must be passed as JSON object",
30 | "required" : true,
31 | "schema" : {
32 | "$ref" : "#/definitions/SimpleStringWrapper"
33 | }
34 | } ],
35 | "responses" : {
36 | "200" : {
37 | "description" : "successful operation",
38 | "schema" : {
39 | "type" : "string"
40 | }
41 | }
42 | }
43 | }
44 | },
45 | "/wrappers/cookie" : {
46 | "get" : {
47 | "operationId" : "stringWrapperCookie",
48 | "produces" : [ "application/json" ],
49 | "parameters" : [ {
50 | "name" : "wrapper",
51 | "in" : "cookie",
52 | "description" : "Must be passed as String",
53 | "required" : true,
54 | "type" : "string"
55 | } ],
56 | "responses" : {
57 | "200" : {
58 | "description" : "successful operation",
59 | "schema" : {
60 | "type" : "string"
61 | }
62 | }
63 | }
64 | }
65 | },
66 | "/wrappers/header" : {
67 | "get" : {
68 | "operationId" : "stringWrapperHeader",
69 | "produces" : [ "application/json" ],
70 | "parameters" : [ {
71 | "name" : "wrapper",
72 | "in" : "header",
73 | "description" : "Must be passed as String",
74 | "required" : true,
75 | "type" : "string"
76 | } ],
77 | "responses" : {
78 | "200" : {
79 | "description" : "successful operation",
80 | "schema" : {
81 | "type" : "string"
82 | }
83 | }
84 | }
85 | }
86 | },
87 | "/wrappers/param" : {
88 | "get" : {
89 | "operationId" : "stringWrapperParam",
90 | "produces" : [ "application/json" ],
91 | "parameters" : [ {
92 | "name" : "wrapper",
93 | "in" : "query",
94 | "description" : "Must be passed as String",
95 | "required" : true,
96 | "type" : "string"
97 | } ],
98 | "responses" : {
99 | "200" : {
100 | "description" : "successful operation",
101 | "schema" : {
102 | "type" : "string"
103 | }
104 | }
105 | }
106 | }
107 | },
108 | "/wrappers/path/{wrapper}" : {
109 | "get" : {
110 | "operationId" : "stringWrapperPath",
111 | "produces" : [ "application/json" ],
112 | "parameters" : [ {
113 | "name" : "wrapper",
114 | "in" : "path",
115 | "description" : "Must be passed as String",
116 | "required" : true,
117 | "type" : "string"
118 | } ],
119 | "responses" : {
120 | "200" : {
121 | "description" : "successful operation",
122 | "schema" : {
123 | "type" : "string"
124 | }
125 | }
126 | }
127 | }
128 | }
129 | },
130 | "securityDefinitions" : {
131 | "api_key" : {
132 | "type" : "apiKey",
133 | "name" : "api_key",
134 | "in" : "header"
135 | },
136 | "basicAuth" : {
137 | "type" : "basic"
138 | },
139 | "petstore_auth" : {
140 | "type" : "oauth2",
141 | "authorizationUrl" : "http://swagger.io/api/oauth/dialog",
142 | "flow" : "implicit",
143 | "scopes" : {
144 | "write:pets" : "modify pets in your account",
145 | "read:pets" : "read your pets"
146 | }
147 | }
148 | },
149 | "definitions" : {
150 | "SimpleStringWrapper" : {
151 | "type" : "object",
152 | "properties" : {
153 | "value" : {
154 | "type" : "string"
155 | }
156 | }
157 | }
158 | }
159 | }
--------------------------------------------------------------------------------
/src/test/resources/override.map:
--------------------------------------------------------------------------------
1 | com.wordnik.sample.model.PetName:java.lang.String
2 | com.wordnik.sample.model.PetId: java.math.BigInteger
3 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-enhanced-operation-id.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | false
12 | {{className}}_{{methodName}}_{{httpMethod}}
13 |
14 | com.wordnik.jaxrs
15 |
16 |
17 | http
18 | https
19 |
20 |
21 |
22 | basicAuth
23 | basic
24 |
25 |
26 | api_key_2
27 | apiKey
28 | header
29 |
30 |
31 | /securityDefinition.json
32 |
33 |
34 | json
35 | ${basedir}/generated/swagger-ui-enhanced-operation-id
36 | com.wordnik.jaxrs.VendorExtensionsJaxrsReader
37 | true
38 | http://www.example.com/restapi/doc
39 | /override.map
40 |
41 | secret-property
42 | another-secret-property
43 | exclude-when-jev-option-not-set
44 |
45 |
46 | com.wordnik.sample.VendorExtensionWithoutReader
47 |
48 |
49 |
50 |
51 |
52 |
53 | compile
54 |
55 | generate
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-externalDocs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | false
12 |
13 | com.wordnik.jaxrs
14 |
15 |
16 | http
17 | https
18 |
19 |
20 |
21 | basicAuth
22 | basic
23 |
24 |
25 | api_key_2
26 | apiKey
27 | header
28 |
29 |
30 | /securityDefinition.json
31 |
32 |
33 |
37 | classpath:/templates/strapdown.html.hbs
38 | ${basedir}/generated/document.html
39 | json
40 | ${basedir}/generated/swagger-ui
41 | com.wordnik.jaxrs.VendorExtensionsJaxrsReader
42 | true
43 | http://www.example.com/restapi/doc
44 | /override.map
45 |
46 | secret-property
47 | another-secret-property
48 | exclude-when-jev-option-not-set
49 |
50 |
51 | com.wordnik.sample.VendorExtensionWithoutReader
52 |
53 |
54 | Example external docs
55 | https://example.com/docs
56 |
57 |
58 |
59 |
60 |
61 |
62 | compile
63 |
64 | generate
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-feature-fail.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | false
12 |
13 | com.wordnik.jaxrs
14 |
15 |
16 | http
17 | https
18 |
19 |
20 |
21 | basicAuth
22 | basic
23 |
24 |
25 | api_key_2
26 | apiKey
27 | header
28 |
29 |
30 | /securityDefinition.json
31 |
32 |
33 |
37 | classpath:/templates/strapdown.html.hbs
38 | ${basedir}/generated/document.html
39 | json
40 | ${basedir}/generated/swagger-ui
41 | com.wordnik.jaxrs.VendorExtensionsJaxrsReader
42 | true
43 | http://www.example.com/restapi/doc
44 | /override.map
45 |
46 | secret-property
47 | another-secret-property
48 | exclude-when-jev-option-not-set
49 |
50 |
51 | com.wordnik.sample.VendorExtensionWithoutReader
52 |
53 |
54 |
55 |
56 | com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING
57 | com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS
58 |
59 |
60 |
61 |
62 | compile
63 |
64 | generate
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-springmvc-enhanced-operation-id.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | true
12 | {{className}}_{{methodName}}_{{httpMethod}}
13 |
14 | com.wordnik.springmvc
15 |
16 |
17 | http
18 | https
19 |
20 | www.example.com:8080
21 | /api
22 |
23 | Swagger Maven Plugin Sample
24 | v1
25 |
28 |
29 | This is a sample.
30 |
31 |
32 | http://www.github.com/kongchen/swagger-maven-plugin
33 |
34 |
35 | kongchen@gmail.com
36 | Kong Chen
37 | http://kongch.com
38 |
39 |
40 | http://www.apache.org/licenses/LICENSE-2.0.html
41 | Apache 2.0
42 |
43 |
44 |
45 |
46 | basicAuth
47 | basic
48 |
49 |
50 | /securityDefinition.json
51 |
52 |
53 | json
54 | ${basedir}/generated/swagger-ui-spring-enhanced-operation-id
55 | com.wordnik.springmvc.VendorExtensionsSpringMvcReader
56 | http://www.example.com/restapi/doc
57 | /override.map
58 |
59 | secret-property
60 | another-secret-property
61 | exclude-when-jev-option-not-set
62 |
63 |
64 | com.wordnik.sample.VendorExtensionWithoutReader
65 |
66 |
67 |
68 |
69 |
70 |
71 | compile
72 |
73 | generate
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-springmvc-skip-inherited.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | true
12 | true
13 |
14 | com.wordnik.spring.skipinherited
15 |
16 |
17 | http
18 | https
19 |
20 | www.example.com:8080
21 | /api
22 |
23 | Swagger Maven Plugin Sample
24 | v1
25 |
28 |
29 | This is a sample.
30 |
31 |
32 | http://www.github.com/kongchen/swagger-maven-plugin
33 |
34 |
35 | kongchen@gmail.com
36 | Kong Chen
37 | http://kongch.com
38 |
39 |
40 | http://www.apache.org/licenses/LICENSE-2.0.html
41 | Apache 2.0
42 |
43 |
44 |
45 |
46 | basicAuth
47 | basic
48 |
49 |
50 | /securityDefinition.json
51 |
52 |
53 | json
54 | ${basedir}/generated/swagger-ui-spring-skip-inherited
55 | com.wordnik.springmvc.VendorExtensionsSpringMvcReader
56 | http://www.example.com/restapi/doc
57 | /override.map
58 |
59 | secret-property
60 | another-secret-property
61 | exclude-when-jev-option-not-set
62 |
63 |
64 | com.wordnik.sample.VendorExtensionWithoutReader
65 |
66 |
67 |
68 |
69 |
70 |
71 | compile
72 |
73 | generate
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-springmvc-string-wrapper-model.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | true
12 |
13 | com.wordnik.stringwrapper
14 |
15 |
16 | http
17 | https
18 |
19 | www.example.com:8080
20 | /api
21 |
22 | Swagger Maven Plugin Sample
23 | v1
24 |
27 |
28 | This is a sample.
29 |
30 |
31 | http://www.github.com/kongchen/swagger-maven-plugin
32 |
33 |
34 | kongchen@gmail.com
35 | Kong Chen
36 | http://kongch.com
37 |
38 |
39 | http://www.apache.org/licenses/LICENSE-2.0.html
40 | Apache 2.0
41 |
42 |
43 |
44 |
45 | basicAuth
46 | basic
47 |
48 |
49 | /securityDefinition.json
50 |
51 |
52 | json
53 | ${basedir}/generated/swagger-ui-spring-string-wrapper-model
54 | com.wordnik.springmvc.VendorExtensionsSpringMvcReader
55 | http://www.example.com/restapi/doc
56 |
57 | secret-property
58 | another-secret-property
59 | exclude-when-jev-option-not-set
60 |
61 |
62 | com.wordnik.sample.VendorExtensionWithoutReader
63 |
64 |
65 |
66 |
67 |
68 |
69 | compile
70 |
71 | generate
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-springmvc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | true
12 |
13 | com.wordnik.springmvc
14 |
15 |
16 | http
17 | https
18 |
19 | www.example.com:8080
20 | /api
21 |
22 | Swagger Maven Plugin Sample
23 | v1
24 |
27 |
28 | This is a sample.
29 |
30 |
31 | http://www.github.com/kongchen/swagger-maven-plugin
32 |
33 |
34 | kongchen@gmail.com
35 | Kong Chen
36 | http://kongch.com
37 |
38 |
39 | http://www.apache.org/licenses/LICENSE-2.0.html
40 | Apache 2.0
41 |
42 |
43 |
44 |
45 | basicAuth
46 | basic
47 |
48 |
49 | /securityDefinition.json
50 |
51 |
52 |
56 | classpath:/templates/strapdown.html.hbs
57 | ${basedir}/generated/document-spring.html
58 | json
59 | ${basedir}/generated/swagger-ui-spring
60 | com.wordnik.springmvc.VendorExtensionsSpringMvcReader
61 | http://www.example.com/restapi/doc
62 | /override.map
63 |
64 | secret-property
65 | another-secret-property
66 | exclude-when-jev-option-not-set
67 |
68 |
69 | com.wordnik.sample.VendorExtensionWithoutReader
70 |
71 |
72 |
73 |
74 |
75 |
76 | compile
77 |
78 | generate
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config-swaggerreader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | false
12 |
13 | com.wordnik.jaxrs
14 |
15 |
16 | http
17 | https
18 |
19 |
20 |
21 | basicAuth
22 | basic
23 |
24 |
25 | /securityDefinition.json
26 |
27 |
28 |
32 | classpath:/templates/strapdown.html.hbs
33 | ${basedir}/generated/document.html
34 | json
35 | ${basedir}/generated/swagger-ui
36 | com.github.kongchen.swagger.docgen.reader.SwaggerReader
37 | true
38 | http://www.example.com/restapi/doc
39 | /override.map
40 |
41 | secret-property
42 | another-secret-property
43 | exclude-when-jev-option-not-set
44 |
45 |
46 | com.wordnik.sample.VendorExtensionWithoutReader
47 |
48 |
49 |
50 |
51 |
52 |
53 | compile
54 |
55 | generate
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/src/test/resources/plugin-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.github.kongchen
6 | swagger-maven-plugin
7 | 3.0-M2-SNAPSHOT
8 |
9 |
10 |
11 | false
12 |
13 | com.wordnik.jaxrs
14 |
15 |
16 | http
17 | https
18 |
19 |
20 |
21 | basicAuth
22 | basic
23 |
24 |
25 | api_key_2
26 | apiKey
27 | header
28 |
29 |
30 | /securityDefinition.json
31 |
32 |
33 |
37 | classpath:/templates/strapdown.html.hbs
38 | ${basedir}/generated/document.html
39 | json
40 | ${basedir}/generated/swagger-ui
41 | com.wordnik.jaxrs.VendorExtensionsJaxrsReader
42 | true
43 | http://www.example.com/restapi/doc
44 | /override.map
45 |
46 | secret-property
47 | another-secret-property
48 | exclude-when-jev-option-not-set
49 |
50 |
51 | com.wordnik.sample.VendorExtensionWithoutReader
52 |
53 |
54 |
55 |
56 | com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING
57 | com.fasterxml.jackson.core.JsonParser$Feature.ALLOW_NUMERIC_LEADING_ZEROS
58 |
59 |
60 | com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS
61 |
62 |
63 |
64 |
65 | compile
66 |
67 | generate
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/test/resources/securityDefinition.json:
--------------------------------------------------------------------------------
1 | {
2 | "api_key": {
3 | "type": "apiKey",
4 | "name": "api_key",
5 | "in": "header"
6 | },
7 | "petstore_auth": {
8 | "type": "oauth2",
9 | "authorizationUrl": "http://swagger.io/api/oauth/dialog",
10 | "flow": "implicit",
11 | "scopes": {
12 | "write:pets": "modify pets in your account",
13 | "read:pets": "read your pets"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/test/resources/templates/markdown.hbs:
--------------------------------------------------------------------------------
1 | #{{#info}}{{title}}
2 |
3 |
4 | ## {{join schemes " | "}}://{{host}}{{basePath}}
5 |
6 |
7 | {{description}}
8 |
9 | {{#contact}}
10 | [**Contact the developer**](mailto:{{email}})
11 | {{/contact}}
12 |
13 | **Version** {{version}}
14 |
15 | [**Terms of Service**]({{termsOfService}})
16 |
17 | {{#license}}[**{{name}}**]({{url}}){{/license}}
18 |
19 | {{/info}}
20 |
21 | {{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}}
22 |
23 | {{#if produces}}**Produces:** {{join produces ", "}}{{/if}}
24 |
25 | {{#if securityDefinitions}}
26 | # Security Definitions
27 | {{/if}}
28 | {{> security}}
29 |
30 | # APIs
31 |
32 | {{#each paths}}
33 | ## {{@key}}
34 | {{#this}}
35 | {{#get}}
36 | ### GET
37 | {{> operation}}
38 | {{/get}}
39 |
40 | {{#put}}
41 | ### PUT
42 | {{> operation}}
43 | {{/put}}
44 |
45 | {{#post}}
46 | ### POST
47 |
48 | {{> operation}}
49 |
50 | {{/post}}
51 |
52 | {{#delete}}
53 | ### DELETE
54 | {{> operation}}
55 | {{/delete}}
56 |
57 | {{#option}}
58 | ### OPTION
59 | {{> operation}}
60 | {{/option}}
61 |
62 | {{#patch}}
63 | ### PATCH
64 | {{> operation}}
65 | {{/patch}}
66 |
67 | {{#head}}
68 | ### HEAD
69 | {{> operation}}
70 | {{/head}}
71 |
72 | {{/this}}
73 | {{/each}}
74 |
75 | # Definitions
76 | {{#each definitions}}
77 | ## {{@key}}
78 |
79 |
80 |
81 | name |
82 | type |
83 | required |
84 | description |
85 | example |
86 |
87 | {{#each this.properties}}
88 |
89 | {{@key}} |
90 |
91 | {{#ifeq type "array"}}
92 | {{#items.$ref}}
93 | {{type}}[{{basename items.$ref}}]
94 | {{/items.$ref}}
95 | {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}}
96 | {{else}}
97 | {{#$ref}}{{basename $ref}}{{/$ref}}
98 | {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}}
99 | {{/ifeq}}
100 | |
101 | {{#required}}required{{/required}}{{^required}}optional{{/required}} |
102 | {{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}} |
103 | {{example}} |
104 |
105 | {{/each}}
106 |
107 | {{/each}}
108 |
109 |
--------------------------------------------------------------------------------
/src/test/resources/templates/operation.hbs:
--------------------------------------------------------------------------------
1 | {{#deprecated}}-deprecated-{{/deprecated}}
2 | {{summary}}
3 |
4 | {{description}}
5 |
6 | {{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}})
7 | {{/if}}
8 |
9 | {{#if security}}
10 | #### Security
11 | {{/if}}
12 |
13 | {{#security}}
14 | {{#each this}}
15 | * {{@key}}
16 | {{#this}} * {{this}}
17 | {{/this}}
18 | {{/each}}
19 | {{/security}}
20 |
21 | #### Request
22 |
23 | {{#if consumes}}
24 | **Content-Type: ** {{join consumes ", "}}{{/if}}
25 |
26 | ##### Parameters
27 | {{#if parameters}}
28 |
29 |
30 | Name |
31 | Located in |
32 | Required |
33 | Description |
34 | Default |
35 | Schema |
36 |
37 | {{/if}}
38 |
39 | {{#parameters}}
40 |
41 | {{name}} |
42 | {{in}} |
43 | {{#if required}}yes{{else}}no{{/if}} |
44 | {{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}} |
45 | - |
46 | {{#ifeq in "body"}}
47 |
48 | {{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{/ifeq}}
49 | {{#schema.$ref}}{{basename schema.$ref}} {{/schema.$ref}}
50 | |
51 | {{else}}
52 | {{#ifeq type "array"}}
53 | Array[{{items.type}}] ({{collectionFormat}}) |
54 | {{else}}
55 | {{type}} {{#format}}({{format}}){{/format}} |
56 | {{/ifeq}}
57 | {{/ifeq}}
58 |
59 | {{/parameters}}
60 | {{#if parameters}}
61 |
62 | {{/if}}
63 |
64 |
65 | #### Response
66 |
67 | {{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}}
68 |
69 |
70 | | Status Code | Reason | Response Model |
71 | |-------------|-------------|----------------|
72 | {{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}{{basename schema.$ref}}{{/schema.$ref}}{{^schema.$ref}}{{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{else}}{{schema.type}}{{/ifeq}}{{/schema.$ref}}{{^schema}} - {{/schema}}|
73 | {{/each}}
74 |
--------------------------------------------------------------------------------
/src/test/resources/templates/security.hbs:
--------------------------------------------------------------------------------
1 | {{#each securityDefinitions}}
2 | ### {{@key}}
3 | {{#this}}
4 | {{#ifeq type "oauth2"}}
5 |
6 |
7 | type |
8 | {{type}} |
9 |
10 | {{#if description}}
11 |
12 | description |
13 | {{description}} |
14 |
15 | {{/if}}
16 | {{#if authorizationUrl}}
17 |
18 | authorizationUrl |
19 | {{authorizationUrl}} |
20 |
21 | {{/if}}
22 | {{#if flow}}
23 |
24 | flow |
25 | {{flow}} |
26 |
27 | {{/if}}
28 | {{#if tokenUrl}}
29 |
30 | tokenUrl |
31 | {{tokenUrl}} |
32 |
33 | {{/if}}
34 | {{#if scopes}}
35 |
36 | scopes |
37 | {{#each scopes}}
38 | {{@key}} |
39 | {{this}} |
40 |
41 |
42 | {{/each}}
43 |
44 | {{/if}}
45 |
46 | {{/ifeq}}
47 | {{#ifeq type "apiKey"}}
48 |
49 |
50 | type |
51 | {{type}} |
52 |
53 | {{#if description}}
54 |
55 | description |
56 | {{description}} |
57 |
58 | {{/if}}
59 | {{#if name}}
60 |
61 | name |
62 | {{name}} |
63 |
64 | {{/if}}
65 | {{#if in}}
66 |
67 | in |
68 | {{in}} |
69 |
70 | {{/if}}
71 |
72 | {{/ifeq}}
73 | {{#ifeq type "basic"}}
74 |
75 |
76 | type |
77 | {{type}} |
78 |
79 | {{#if description}}
80 |
81 | description |
82 | {{description}} |
83 |
84 | {{/if}}
85 |
86 | {{/ifeq}}
87 | {{/this}}
88 | {{/each}}
--------------------------------------------------------------------------------
/src/test/resources/templates/strapdown.html.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 | API Document
4 |
5 |
6 | {{>markdown}}
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------