Last active
August 2, 2022 02:04
-
-
Save FrancescoJo/70f3e78d7f53aaa243dd746159343078 to your computer and use it in GitHub Desktop.
Are there a spring RestController based codegen like this?
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
// given: | |
interface SomeController { | |
@RequestMapping(GET, "/someApi") | |
fun someApi(): Response1 | |
} | |
@RestController | |
class SomeControllerImpl : SomeController { | |
override fun someApi1(): Response1 { | |
// ... | |
} | |
@RequestMapping(POST, "/someApi2") | |
fun someApi2(@RequestBody someRequest: Request1): ResponseEntity<Response1> { | |
// .. | |
} | |
} | |
data class Request1( | |
val field1: String, | |
val field2: Int | |
) | |
data class Response1( | |
val resp1: Double, | |
val resp2: Instant | |
) | |
// expected: | |
// request_1.js: | |
/** | |
* GET /someApi | |
*/ | |
class Request1 { | |
constructor(field1, field2) { | |
this.field1 = field1; | |
this.field2 = field2; | |
} | |
} | |
// response_1.js: | |
/** | |
* POST /someApi2 | |
*/ | |
class Response1 { | |
constructor(resp1, resp2) { | |
this.resp1 = resp1; | |
this.resp2 = resp2; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment