Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -210,7 +210,7 @@ protected boolean isSkipMethod(Method method) {
}

ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
if (apiOperation != null) {
if (apiOperation != null && apiOperation.hidden()) {
return apiOperation.hidden();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package io.servicecomb.swagger.generator.core;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;

import java.util.Arrays;
import java.util.Map;

Expand Down Expand Up @@ -69,6 +73,9 @@ interface ApiOperationAnnotation {

@ApiOperation(value = "aaa", response = Integer.class, responseContainer = "Set")
int testSet();

@ApiOperation(value = "aaa", hidden = true)
int testHidden();
}

interface UnknownResponseContainer {
Expand All @@ -88,6 +95,7 @@ public void testApiOperation() {
testMap(swagger.getPath("/testMap"));
testList(swagger.getPath("/testList"));
testSet(swagger.getPath("/testSet"));
assertThat(swagger.getPath("/testHidden"), is(nullValue()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,9 @@ public String query(@QueryParam(value = "query") String query) {
public String queryComplex(@QueryParam(value = "querys") List<User> querys) {
return String.format("%s", querys);
}

@ApiOperation(value = "")
public void ignoredNonRestful() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public void testEmptyPath() throws Exception {
UnitTestSwaggerUtils.testSwagger("schemas/emptyPath.yaml", context, Echo.class, "emptyPath");
}

@Test
public void testNonRestful() throws Exception {
UnitTestSwaggerUtils.testSwagger("schemas/emptyContract.yaml", context, Echo.class, "ignoredNonRestful");
}

@Test
public void testClassMethodNoPath() throws Exception {
UnitTestSwaggerUtils.testException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
swagger: "2.0"
info:
version: "1.0.0"
title: "swagger definition for io.servicecomb.swagger.generator.jaxrs.Echo"
x-java-interface: "gen.cse.ms.ut.EchoIntf"
basePath: "/Echo"
consumes:
- "application/json"
produces:
- "application/json"
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import io.swagger.annotations.ApiOperation;

@RequestMapping(path = "MethodEmptyPath")
public class MethodEmptyPath {

Expand Down Expand Up @@ -50,4 +52,11 @@ public void usingDeleteMapping() {
public void usingPatchMapping() {

}

// this will be ignored in the generation of service contract
// as ApiOperation is not a restful annotation
@ApiOperation(value = "")
public void ignoredNonRestful() {

}
}