Created by: Jesse0Michael
Enhance the default go api server generation to define interfaces for an API's routes and services. Handle an endpoint's http binding in the generated router and the skeleton for the service logic in an API service.
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first. -
Filed the PR against the correct branch: master
,4.1.x
,5.0.x
. Default:master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
Description of the PR
Made some changes to the go-api-server code generations build out router and service interfaces. The Router interface implementation handles the http request/response binding. The service interface implementation provides a skeleton for the server logic (which can easily be updated to include any data access services or whatever you might need in your server logic) I'm not sure if this a minor or major change, but I have set it against 4.2.x
The way of separating the business logic into services and route bindings into routers and using interfaces is closer to how I would normally create apis in go. So I thought this might be helpful to others as well. Please let me know if there anything I am doing incorrectly or anything I should change to match any openapi design principles.
There are still improvements that can be made (like a better way of handling errors by default.) But I thought this was far enough along and working well enough to begin a discussion! Samples generated with go-petstore-server.sh
. Thanks!