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 @@ -83,6 +83,7 @@ public class SpringCodegen extends AbstractJavaCodegen
public static final String BASE_PACKAGE = "basePackage";
public static final String INTERFACE_ONLY = "interfaceOnly";
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 SINGLE_CONTENT_TYPES = "singleContentTypes";
public static final String VIRTUAL_SERVICE = "virtualService";
Expand Down Expand Up @@ -110,6 +111,7 @@ public class SpringCodegen extends AbstractJavaCodegen
protected String basePackage = "org.openapitools";
protected boolean interfaceOnly = false;
protected boolean useFeignClientUrl = true;
protected boolean useFeignClient = false;
protected boolean delegatePattern = false;
protected boolean delegateMethod = false;
protected boolean singleContentTypes = false;
Expand Down Expand Up @@ -491,6 +493,8 @@ public void processOpts() {
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
this.setSingleContentTypes(true);
}
additionalProperties.put(USE_FEIGN_CLIENT, "true");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I guess this didn't exist, it just relied on importing the correct apiClient.mustache instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes correct

this.setUseFeignClient(true);
} else {
apiTemplateFiles.put("apiController.mustache", "Controller.java");
supportingFiles.add(new SupportingFile("application.mustache",
Expand Down Expand Up @@ -846,6 +850,10 @@ public void setSingleContentTypes(boolean singleContentTypes) {
this.singleContentTypes = singleContentTypes;
}

public void setUseFeignClient( boolean useFeignClient ) {
this.useFeignClient = useFeignClient;
}

public void setSkipDefaultInterface(boolean skipDefaultInterface) {
this.skipDefaultInterface = skipDefaultInterface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ import javax.annotation.Generated;
{{#virtualService}}
@VirtualService
{{/virtualService}}
{{^useFeignClient}}
{{=<% %>=}}
@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
<%={{ }}=%>
{{/useFeignClient}}
public interface {{classname}} {
{{#jdk8-default-interface}}
{{^isDelegate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,20 @@ public void testRequestMappingAnnotation() throws IOException {
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
public void testSettersForConfigValues() throws Exception {
final SpringCodegen codegen = new SpringCodegen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Pet", description = "Everything about your Pets")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface PetApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Store", description = "Access to Petstore orders")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface StoreApi {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "User", description = "Operations about user")
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
public interface UserApi {

/**
Expand Down