I am using jetty server that is initiated with a port and threadconnectionpool. I add the handlers to the contexts object and then all my APIs are in the com.example.handler package.
I am very very new to the OpenAPI and I want to document all my above apis. How do I get started from scratch? I mean what kind of dependencies do I need and also what should I do to hook up my project with openApi?
@joejoyce this is a great suggestion. Infact I am looking for solution in Jakarta namespace only. I will try to use this. But would this automatically generate the OpenAPI yaml after code annotation? Or I will have to use some tool to get the yaml first? I am trying to generate yaml from code annotations. Can you provide something about this confusion?
@anirtek yes indeed; using the swagger-core method, the Swagger/OAS contract is generated from an API based on the meta-data added against the various resources, methods and controllers. This meta-data will generate the contract, client-side code, and other artifacts during runtime. Typically, this meta-data will be in the form of code annotations.
You'll find some more useful documentation on this here.
Hope this helps!
@joejoyce I think swagger core project is what I am looking for. But I need some more help about this.
In the Where to start section, it says -
since version 2.0.5, swagger-core project also provides maven and gradle plugins to resolve an OpenAPI definition at build time. As these are based on the same resolving and configuration mechanisms, most information in the wiki applies also in this case.
I have added the swagger-core Gradle plugin in the id section and other dependencies in the Jakarta namespace in dependencies.
Now if my code is annotated, should I see the swagger-ui directly when I run my project or I need to configure swagger-ui in my main method?
id "io.swagger.core.v3.swagger-gradle-plugin" version "2.1.9"
But since I am using Jetty 11 which works with jakarta namespace only, do I need to set buildClasspath = classpath so that my gradle dependencies will refer to jakarta based builds? If I use the plugin with suffix `jakarta`, that does not seem to have fetching the packages. Can someone please help?