forked from loafle/openapi-generator-original
Remove wrong request mapping for feign clients (#13546)
* Remove request mapping * Fix bug for feign clients * Fix test * Fix test files * Rebuild * Revert change
This commit is contained in:
parent
64c756c5fc
commit
0a69f11526
@ -83,6 +83,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
public static final String BASE_PACKAGE = "basePackage";
|
public static final String BASE_PACKAGE = "basePackage";
|
||||||
public static final String INTERFACE_ONLY = "interfaceOnly";
|
public static final String INTERFACE_ONLY = "interfaceOnly";
|
||||||
public static final String USE_FEIGN_CLIENT_URL = "useFeignClientUrl";
|
public static final String USE_FEIGN_CLIENT_URL = "useFeignClientUrl";
|
||||||
|
public static final String USE_FEIGN_CLIENT = "useFeignClient";
|
||||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||||
public static final String VIRTUAL_SERVICE = "virtualService";
|
public static final String VIRTUAL_SERVICE = "virtualService";
|
||||||
@ -110,6 +111,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
protected String basePackage = "org.openapitools";
|
protected String basePackage = "org.openapitools";
|
||||||
protected boolean interfaceOnly = false;
|
protected boolean interfaceOnly = false;
|
||||||
protected boolean useFeignClientUrl = true;
|
protected boolean useFeignClientUrl = true;
|
||||||
|
protected boolean useFeignClient = false;
|
||||||
protected boolean delegatePattern = false;
|
protected boolean delegatePattern = false;
|
||||||
protected boolean delegateMethod = false;
|
protected boolean delegateMethod = false;
|
||||||
protected boolean singleContentTypes = false;
|
protected boolean singleContentTypes = false;
|
||||||
@ -491,6 +493,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
|
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
|
||||||
this.setSingleContentTypes(true);
|
this.setSingleContentTypes(true);
|
||||||
}
|
}
|
||||||
|
additionalProperties.put(USE_FEIGN_CLIENT, "true");
|
||||||
|
this.setUseFeignClient(true);
|
||||||
} else {
|
} else {
|
||||||
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
||||||
supportingFiles.add(new SupportingFile("application.mustache",
|
supportingFiles.add(new SupportingFile("application.mustache",
|
||||||
@ -846,6 +850,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
this.singleContentTypes = singleContentTypes;
|
this.singleContentTypes = singleContentTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseFeignClient( boolean useFeignClient ) {
|
||||||
|
this.useFeignClient = useFeignClient;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSkipDefaultInterface(boolean skipDefaultInterface) {
|
public void setSkipDefaultInterface(boolean skipDefaultInterface) {
|
||||||
this.skipDefaultInterface = skipDefaultInterface;
|
this.skipDefaultInterface = skipDefaultInterface;
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,11 @@ import javax.annotation.Generated;
|
|||||||
{{#virtualService}}
|
{{#virtualService}}
|
||||||
@VirtualService
|
@VirtualService
|
||||||
{{/virtualService}}
|
{{/virtualService}}
|
||||||
|
{{^useFeignClient}}
|
||||||
{{=<% %>=}}
|
{{=<% %>=}}
|
||||||
@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
|
@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
|
||||||
<%={{ }}=%>
|
<%={{ }}=%>
|
||||||
|
{{/useFeignClient}}
|
||||||
public interface {{classname}} {
|
public interface {{classname}} {
|
||||||
{{#jdk8-default-interface}}
|
{{#jdk8-default-interface}}
|
||||||
{{^isDelegate}}
|
{{^isDelegate}}
|
||||||
|
@ -673,6 +673,20 @@ public class SpringCodegenTest {
|
|||||||
assertFileNotContains(petApiControllerFile.toPath(), "@RequestMapping(\"${openapi.openAPIPetstore.base-path:/v2}\")");
|
assertFileNotContains(petApiControllerFile.toPath(), "@RequestMapping(\"${openapi.openAPIPetstore.base-path:/v2}\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoRequestMappingAnnotation() throws IOException {
|
||||||
|
final SpringCodegen codegen = new SpringCodegen();
|
||||||
|
codegen.setLibrary( "spring-cloud" );
|
||||||
|
|
||||||
|
final Map<String, File> files = generateFiles( codegen, "src/test/resources/2_0/petstore.yaml" );
|
||||||
|
|
||||||
|
// Check that the @RequestMapping annotation is not generated in the Api file
|
||||||
|
final File petApiFile = files.get( "PetApi.java" );
|
||||||
|
JavaFileAssert.assertThat( petApiFile ).assertTypeAnnotations().hasSize( 3 ).containsWithName( "Validated" )
|
||||||
|
.containsWithName( "Generated" ).containsWithName( "Tag" );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSettersForConfigValues() throws Exception {
|
public void testSettersForConfigValues() throws Exception {
|
||||||
final SpringCodegen codegen = new SpringCodegen();
|
final SpringCodegen codegen = new SpringCodegen();
|
||||||
|
@ -27,7 +27,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Pet", description = "Everything about your Pets")
|
@Api(value = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Store", description = "Access to Petstore orders")
|
@Api(value = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "User", description = "Operations about user")
|
@Api(value = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Pet", description = "Everything about your Pets")
|
@Api(value = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Store", description = "Access to Petstore orders")
|
@Api(value = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "User", description = "Operations about user")
|
@Api(value = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Pet", description = "Everything about your Pets")
|
@Api(value = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Store", description = "Access to Petstore orders")
|
@Api(value = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "User", description = "Operations about user")
|
@Api(value = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Pet", description = "Everything about your Pets")
|
@Api(value = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "Store", description = "Access to Petstore orders")
|
@Api(value = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Api(value = "User", description = "Operations about user")
|
@Api(value = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "Pet", description = "Everything about your Pets")
|
@Tag(name = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "Store", description = "Access to Petstore orders")
|
@Tag(name = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "User", description = "Operations about user")
|
@Tag(name = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "Pet", description = "Everything about your Pets")
|
@Tag(name = "Pet", description = "Everything about your Pets")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface PetApi {
|
public interface PetApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +33,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "Store", description = "Access to Petstore orders")
|
@Tag(name = "Store", description = "Access to Petstore orders")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface StoreApi {
|
public interface StoreApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ import javax.annotation.Generated;
|
|||||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||||
@Validated
|
@Validated
|
||||||
@Tag(name = "User", description = "Operations about user")
|
@Tag(name = "User", description = "Operations about user")
|
||||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user