Created by: sdstolworthy
In response to the ongoing conversation in https://github.com/OpenAPITools/openapi-generator/issues/3547, I added two flags to the go-server
generator.
outputAsLibrary
generates output intended to be included in a larger go project. It removes the Dockerfile
, main.go
, and go.mod
from the rendered output.
onlyInterfaces
removes the factory functions New{{classname}}Service
, which expects implementations to be added to the generated templates, and those templates to be added to .openapi-generator-ignore
.
Using both flags together will create a package that can be incorporated in an existing project, and whose service must be implemented in the composition root of the larger project, rather than in the generated output files.
This is a small step towards the larger goal of #3547, which is to bring the output more in line with a standard go project structure, and to provide more flexibility around how the generated files are used.
I propose this as an intermediate change, because it allows consumers to effectively use the generated code within a larger project, but should not create breaking changes for users of the current behavior.
PR checklist
- [x ] Read the contribution guidelines.
-
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
(5.3.0),6.0.x
-
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @wing328