papsign / Ktor-OpenAPI-Generator

Ktor OpenAPI/Swagger 3 Generator
Apache License 2.0
241 stars 42 forks source link

Throw should be assignable on specific actions #72

Closed brizzbuzz closed 4 years ago

brizzbuzz commented 4 years ago

Hola,

Right now, it appears that .throws() is only actionable on the Route... curious what people think about also allowing throws to be assigned at the individual get, post, actions. For example, right now I can do

route("/example").throws(exe1, exe2) {
  get { .. }
  post { .. }
}

However, since get/post quite often will have differing exceptions, it would be useful to be able to assign throws documentation to the individual actions, ie

route("/example") {
  get().throws(exe1) { .. }
  post().throws(exe2) { .. }
}
brizzbuzz commented 4 years ago

Dug further into the code, this functionality is achievable instead through the NormalOpenApiRoute DSL like so

route( "/example") {
  throws(exe1) {
    get { .. }
  }
  throws(exe2) {
    post { .. }
  }
}