[Spring] Use tag operation grouping for spring-cloud

Instead of basepath based grouping that is used by Spring boot/MVC
This commit is contained in:
cbornet 2016-11-15 18:46:48 +01:00
parent 97924c78a0
commit 4a196a9187
15 changed files with 43 additions and 39 deletions

View File

@ -221,27 +221,31 @@ public class SpringCodegen extends AbstractJavaCodegen {
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
}
int pos = basePath.indexOf("/");
if (pos > 0) {
basePath = basePath.substring(0, pos);
}
if(library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
}
int pos = basePath.indexOf("/");
if (pos > 0) {
basePath = basePath.substring(0, pos);
}
if (basePath == "") {
basePath = "default";
if (basePath.equals("")) {
basePath = "default";
} else {
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
opList.add(co);
co.baseName = basePath;
} else {
co.subresourceOperation = !co.path.isEmpty();
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
}
List<CodegenOperation> opList = operations.get(basePath);
if (opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
opList.add(co);
co.baseName = basePath;
}
@Override

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
@ -18,7 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Api(value = "pet", description = "the pet API")
@Api(value = "Pet", description = "the Pet API")
public interface PetApi {
@ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {

View File

@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Api(value = "store", description = "the store API")
@Api(value = "Store", description = "the Store API")
public interface StoreApi {
@ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", })

View File

@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Api(value = "user", description = "the user API")
@Api(value = "User", description = "the User API")
public interface UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", })

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Client;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.LocalDate;
import java.math.BigDecimal;
import io.swagger.annotations.*;
@ -71,8 +71,8 @@ public interface FakeApi {
@ApiResponse(code = 400, message = "Invalid request", response = Void.class),
@ApiResponse(code = 404, message = "Not found", response = Void.class) })
@RequestMapping(value = "/fake",
produces = { "application/json" },
consumes = { "application/json" },
produces = { "*/*" },
consumes = { "*/*" },
method = RequestMethod.GET)
default CompletableFuture<ResponseEntity<Void>> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestPart(value="enumFormStringArray", required=false) List<String> enumFormStringArray,
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;

View File

@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
@ -63,8 +63,8 @@ public interface FakeApi {
@ApiResponse(code = 400, message = "Invalid request", response = Void.class),
@ApiResponse(code = 404, message = "Not found", response = Void.class) })
@RequestMapping(value = "/fake",
produces = { "application/json" },
consumes = { "application/json" },
produces = { "*/*" },
consumes = { "*/*" },
method = RequestMethod.GET)
ResponseEntity<Void> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestPart(value="enumFormStringArray", required=false) List<String> enumFormStringArray,
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,

View File

@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;

View File

@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
@ -63,8 +63,8 @@ public interface FakeApi {
@ApiResponse(code = 400, message = "Invalid request", response = Void.class),
@ApiResponse(code = 404, message = "Not found", response = Void.class) })
@RequestMapping(value = "/fake",
produces = { "application/json" },
consumes = { "application/json" },
produces = { "*/*" },
consumes = { "*/*" },
method = RequestMethod.GET)
ResponseEntity<Void> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestPart(value="enumFormStringArray", required=false) List<String> enumFormStringArray,
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,

View File

@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;

View File

@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;