Skip to content

Instantly share code, notes, and snippets.

@FrancescoJo
Last active August 2, 2022 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescoJo/70f3e78d7f53aaa243dd746159343078 to your computer and use it in GitHub Desktop.
Save FrancescoJo/70f3e78d7f53aaa243dd746159343078 to your computer and use it in GitHub Desktop.
Are there a spring RestController based codegen like this?
// 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