title: What is the proper way to use openapi-generator for generating ktor server stubs
body: <p>When trying to generate server-side stubs for ktor from openapi, the output to me does not really look very usable.</p>
  
  <p>I set up an example project <a href="https://github.com/fnordhusen/ktor-openapi-example" rel="noreferrer">on Github</a>, where the setup can be reviewed. As I need to use maven in my real project, I used it here as well but I guess this should not make a difference to other generation methods.</p>
  
  <p>The relevant part of the POM is this:</p>
  
  <pre><code>&lt;build&gt;
      ...
  
      &lt;plugins&gt;
          ...
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;resources&lt;/id&gt;
                      &lt;phase&gt;compile&lt;/phase&gt;
                      &lt;goals&gt;&lt;goal&gt;copy-resources&lt;/goal&gt;&lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/classes&lt;/outputDirectory&gt;
                          &lt;resources&gt;
                              &lt;resource&gt;
                                  &lt;directory&gt;${project.basedir}/resources&lt;/directory&gt;
                              &lt;/resource&gt;
                          &lt;/resources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>What will be generated is the following:</p>
  
  <ul>
  <li>Data Model</li>
  <li>A <code>Paths.kt</code> object containing the paths to my routes in ktor-locations format</li>
  <li>An example stub implementing the API as an extension function of <code>io.ktor.routing.Route</code></li>
  <li>A complete application, including configs, Dockerfile, Gradle Files, etc.</li>
  </ul>
  
  <p>Coming from SpringBoot and Swagger, I am a bit confused, as this set of files is not really useful if you want to create an actual application implementing real business logic. I would have expected some default implementation holding single methods that I just need to implement / override. I realize that ktor has no DI built in, so I would also expect to have to extend the <code>routing</code> stub in my application somehow.</p>
  
  <p>However, with this set of generated code, I can really only use the data model and the <code>Paths.kt</code> object. I will have my own application and the default implementation I can not override but need to rewrite completely myself.</p>
  
  <p>So my question is, how to set up a proper ktor application implementing openapi specifications. Do I miss anything or do I really only get the model and <code>Paths.kt</code> to work with? </p>
  
  <p><strong>Edit</strong> </p>
  
  <p>For more clarity: especially with these parts of my application I am not happy to have no support from the tooling:</p>
  
  <pre><code>fun Application.module(testing: Boolean = false) {
      // other setup
  
      routing {
          // some other interfaces I may have
  
          FooApiImpl()
      }
  }
  </code></pre>
  
  <pre><code>/**
   * This Api Implementation has to be written completely manually. No help from the generated Code...
   */
  @KtorExperimentalLocationsAPI
  fun Route.FooApiImpl() {
      get&lt;Paths.getAllFoos&gt; {
          call.respond(listOf(
              Foo( id = -1, bar = "hello"),
              Foo( id = -2, bar = "world")
          ))
      }
  
      // the path gets named after the first method, which is weird in my eyes.
      post&lt;Paths.getAllFoos&gt; {
          val foo = call.receive&lt;Foo&gt;()
          // fooService.save(foo)
          call.respond(foo)
      }
  
      delete&lt;Paths.deleteFooById&gt; { path -&gt;
          val id = path.id
          // fooService.deleteById(id)
          call.respond(HttpStatusCode.NoContent)
      }
  }
  
  </code></pre>