-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress Generation of Controller / Decorator for specific endpoints
- Loading branch information
Aleksandar Stojsavljevic
committed
Jun 13, 2018
1 parent
4c1bbaa
commit a644f8b
Showing
8 changed files
with
205 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue263RulesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.phoenixnap.oss.ramlplugin.raml2code.github; | ||
|
||
import org.junit.Test; | ||
|
||
import com.phoenixnap.oss.ramlplugin.raml2code.plugin.TestConfig; | ||
import com.phoenixnap.oss.ramlplugin.raml2code.rules.GitHubAbstractRuleTestBase; | ||
import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerDecoratorRule; | ||
|
||
/** | ||
* @author aleksandars | ||
* @since 2.0.2 | ||
*/ | ||
public class Issue263RulesTest extends GitHubAbstractRuleTestBase { | ||
|
||
@Test | ||
public void testDontGenerateForAnnotation() throws Exception { | ||
TestConfig.setDontGenerateForAnnotation("skipThis"); | ||
loadRaml("issue-263.raml"); | ||
rule = new Spring4ControllerDecoratorRule(); | ||
rule.apply(getControllerMetadata(), jCodeModel); | ||
verifyGeneratedCode("Issue263Spring4ControllerDecorator"); | ||
TestConfig.setDontGenerateForAnnotation(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#%RAML 1.0 | ||
title: Booking API | ||
|
||
annotationTypes: | ||
skipThis: | ||
type: boolean | ||
allowedTargets: [Resource, Method] | ||
|
||
/topLevel1: | ||
get: | ||
responses: | ||
200: | ||
body: | ||
application/json: | ||
post: | ||
(skipThis): true | ||
responses: | ||
200: | ||
body: | ||
application/json: | ||
/level2: | ||
put: | ||
body: | ||
application/json: | ||
type: string | ||
/level3: | ||
(skipThis): true | ||
get: | ||
responses: | ||
200: | ||
body: | ||
application/json: | ||
type: integer | ||
/level4: | ||
get: | ||
responses: | ||
200: | ||
body: | ||
application/json: | ||
type: number |
83 changes: 83 additions & 0 deletions
83
src/test/resources/validations/github/Issue263Spring4ControllerDecorator.java.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
-----------------------------------com.gen.test.TopLevel1Controller.java----------------------------------- | ||
|
||
package com.gen.test; | ||
|
||
import javax.validation.Valid; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
|
||
/** | ||
* No description | ||
* (Generated with springmvc-raml-parser [email protected]@) | ||
* | ||
*/ | ||
public interface TopLevel1Controller { | ||
|
||
|
||
/** | ||
* No description | ||
* | ||
*/ | ||
public ResponseEntity<?> getObject(); | ||
|
||
/** | ||
* No description | ||
* | ||
*/ | ||
public ResponseEntity<?> updateString( | ||
@Valid | ||
String string); | ||
|
||
} | ||
-----------------------------------com.gen.test.TopLevel1ControllerDecorator.java----------------------------------- | ||
|
||
package com.gen.test; | ||
|
||
import javax.validation.Valid; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
||
/** | ||
* No description | ||
* (Generated with springmvc-raml-parser [email protected]@) | ||
* | ||
*/ | ||
@RestController | ||
@RequestMapping("/api/topLevel1") | ||
@Validated | ||
public class TopLevel1ControllerDecorator | ||
implements TopLevel1Controller | ||
{ | ||
|
||
@Autowired | ||
private TopLevel1Controller topLevel1ControllerDelegate; | ||
|
||
/** | ||
* No description | ||
* | ||
*/ | ||
@RequestMapping(value = "", method = RequestMethod.GET) | ||
public ResponseEntity<?> getObject() { | ||
return this.topLevel1ControllerDelegate.getObject(); | ||
} | ||
|
||
/** | ||
* No description | ||
* | ||
*/ | ||
@RequestMapping(value = "/level2", method = RequestMethod.PUT) | ||
public ResponseEntity<?> updateString( | ||
@Valid | ||
@RequestBody | ||
String string) { | ||
return this.topLevel1ControllerDelegate.updateString(string); | ||
} | ||
|
||
} | ||
|