Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e908589
Add x-spring-pageable
diyfr Jul 13, 2016
c788a32
Add dependency and autoconfigure boot exclusions
diyfr Jul 13, 2016
a6e3194
Use application.properties.mustache
diyfr Jul 13, 2016
a8a0953
Use application.mustache instead of application.properties
diyfr Jul 13, 2016
1b483da
Update Petstore SpringBoot sample
diyfr Jul 13, 2016
3d070b8
Merge branch 'SpringPagination' of https://github.com/diyfr/swagger-c…
diyfr Jul 13, 2016
35dd54f
add vendor extension x-spring-pageable to sample petstore.json
diyfr Jul 13, 2016
3fe3558
Update vendor extension to x-spring-paginated, move application musta…
diyfr Jul 13, 2016
f89111c
remove springboot excludes
diyfr Jul 13, 2016
5629d46
remove spring-mvc application.mustache to swagger.mustache
diyfr Jul 13, 2016
d8b7bb6
Add dependency and autoconfigure boot exclusions
diyfr Jul 13, 2016
82ae76e
Update Petstore SpringBoot sample
diyfr Jul 13, 2016
e464165
Use application.properties.mustache
diyfr Jul 13, 2016
78cb757
Use application.mustache instead of application.properties
diyfr Jul 13, 2016
2167b8d
add vendor extension x-spring-pageable to sample petstore.json
diyfr Jul 13, 2016
4a61609
Update vendor extension to x-spring-paginated, move application musta…
diyfr Jul 13, 2016
ea8b6ef
remove springboot excludes
diyfr Jul 13, 2016
4d01ad4
remove spring-mvc application.mustache to swagger.mustache
diyfr Jul 13, 2016
a36d68f
Merge branch 'SpringPagination' of https://github.com/diyfr/swagger-c…
diyfr Jul 14, 2016
96d37f5
Upgrade SpringBoot version 1.3.5 to 1.4.0
diyfr Aug 12, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void processOpts() {
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
supportingFiles.add(new SupportingFile("application.properties",
supportingFiles.add(new SupportingFile("swagger.mustache",
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
}
if (library.equals(SPRING_CLOUD_LIBRARY)) {
Expand Down
19 changes: 16 additions & 3 deletions modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import io.swagger.annotations.*;
{{#java8}}
import org.springframework.http.HttpStatus;
{{/java8}}
import org.springframework.data.domain.Pageable;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -34,16 +36,27 @@ public interface {{classname}} {
{{/hasMore}}{{/scopes}}
}{{/isOAuth}}){{#hasMore}},
{{/hasMore}}{{/authMethods}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
@ApiResponses(value = { {{#responses}}
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
{{#vendorExtensions.x-spring-paginated}}
@ApiImplicitParams({
@ApiImplicitParam(name = "page", dataType = "integer", paramType = "query",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a plugin would be nicer

value = "Results page you want to retrieve (0..N)"),
@ApiImplicitParam(name = "size", dataType = "integer", paramType = "query",
value = "Number of records per page."),
@ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query",
value = "Sorting criteria in the format: property(,asc|desc). " +
"Default sort order is ascending. " +
"Multiple sort criteria are supported.")
}){{/vendorExtensions.x-spring-paginated}}
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} })
@RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}
produces = "{{{vendorExtensions.x-accepts}}}",
consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
method = RequestMethod.{{httpMethod}})
{{#java8}}default {{/java8}}{{#async}}{{^java8}}Callable{{/java8}}{{#java8}}CompletableFuture<{{/java8}}{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^java8}};{{/java8}}{{#java8}} {
{{#java8}}default {{/java8}}{{#async}}{{^java8}}Callable{{/java8}}{{#java8}}CompletableFuture<{{/java8}}{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{^java8}};{{/java8}}{{#java8}} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use ApiIgnore but configure .ignoredParameterTypes(Pageable.class) in the docket (only if not using the plugin)

// do some magic!
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
}{{/java8}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ package {{package}};
{{/imports}}

import io.swagger.annotations.*;

import org.springframework.data.domain.Pageable;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
{{/java8}}
Expand All @@ -29,7 +30,7 @@ import java.util.concurrent.Callable;
public class {{classname}}Controller implements {{classname}} {
{{^java8}}{{#operation}}
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}}) {
{{/hasMore}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}) {
// do some magic!{{^async}}
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}}
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#SpringBoot application.properties
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
#server.port=8090

#Remove this exclusion for use Jpa. But don't miss to declare datasource before...
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<version>1.4.0.RELEASE</version>
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down Expand Up @@ -44,6 +44,10 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include spring-data-commons instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbornet I think it is easier to change application.properties than change pom.xml.
If you need persistence (what project do not need) it will change pom for recommender dependency and application.properties for add datasource.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of projects don't use JPA !! Think about NoSQL, Mongo, Cassandra, ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's less intrusive to let the user add spring-boot-starter-data-jpa if he needs JPA and it will not cause any problem to have spring-data-commons in parallel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @cbornet
Next action :

Change dependency to spring-data-common
SpringFox plugin parameter
But I have to leave , I could not go back to the code before mid-August

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you at least have access to your gh account ?
In that case I can PR to your fork and you will just have to merge.

Copy link
Contributor Author

@diyfr diyfr Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbornet via mobile only . no position with git client
Otherwise we demand the integration and adapts after you ?

TODO (for me :) ) update Wiki page for vendor extension...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbornet if you want you can to directly modify the branch of my git repository (access contributor)

</dependency>
<!--SpringFox dependencies -->
<dependency>
<groupId>io.springfox</groupId>
Expand Down Expand Up @@ -74,4 +78,4 @@
</dependency>
{{/java8}}
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Spring MVC swagger.properties
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
Copy link
Contributor

@cbornet cbornet Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server.contextPath is not used by spring-mvc. Must be removed

#server.port=8090
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma seperated strings",
"operationId": "findPetsByStatus",
"x-spring-paginated": true,
"produces": [
"application/json",
"application/xml"
Expand Down
1 change: 1 addition & 0 deletions modules/swagger-codegen/src/test/resources/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"application/json",
"application/xml"
],
"x-spring-pageable":true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x-spring-paginated

"parameters": [
{
"name": "status",
Expand Down
8 changes: 6 additions & 2 deletions samples/server/petstore/springboot/pom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-spring-server</artifactId>
<artifactId>swagger-spring</artifactId>
<packaging>jar</packaging>
<name>swagger-spring-server</name>
<name>swagger-spring</name>
<version>1.0.0</version>
<properties>
<java.version>1.7</java.version>
Expand Down Expand Up @@ -42,6 +42,10 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--SpringFox dependencies -->
<dependency>
<groupId>io.springfox</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.api;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-07-13T14:49:07.020+02:00")

public class ApiException extends Exception{
private int code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-07-13T14:49:07.020+02:00")

public class ApiOriginFilter implements javax.servlet.Filter {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.xml.bind.annotation.XmlTransient;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-07-13T14:49:07.020+02:00")

@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.api;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-07-13T14:49:07.020+02:00")

public class NotFoundException extends ApiException {
private int code;
Expand Down
Loading