Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider generating this mock server #7

Open
displague opened this issue Oct 19, 2023 · 0 comments
Open

Consider generating this mock server #7

displague opened this issue Oct 19, 2023 · 0 comments

Comments

@displague
Copy link
Member

displague commented Oct 19, 2023

Consider generating this mock server.

Using https://github.com/equinix-labs/metal-go as a starting point:

diff --git a/Makefile b/Makefile
index b454ebd..ad3da5b 100644
--- a/Makefile
+++ b/Makefile
@@ -52,14 +52,15 @@ clean:
        rm -rf $(PACKAGE_PREFIX)
 
 codegen:
-       ${OPENAPI_GENERATOR} generate -g go \
+       ${OPENAPI_GENERATOR} generate -g go-server \
                --package-name ${PACKAGE_MAJOR} \
                --http-user-agent "${GIT_REPO}/${PACKAGE_VERSION}" \
                -p packageVersion=${PACKAGE_VERSION} \
                --git-user-id ${GIT_ORG} \
                --git-repo-id ${GIT_REPO}/${PACKAGE_PREFIX} \
                -c /local/config/openapi-generator.json \
-               -o /local/${PACKAGE_PREFIX}/${PACKAGE_MAJOR} \
+               -o /local/ \
+               -p sourceFolder=${PACKAGE_PREFIX}/${PACKAGE_MAJOR} \
                -i /local/${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE}
 
 validate:

The stubs would be created and the current mock implementation could be moved into the stubs.

The option to generate only interfaces could be helpful so that empty stubs return errors until they are actually implemented.
https://openapi-generator.tech/docs/generators/go-server/

One problem that I found with this patch to metal-go is that the directory structure is correctly defined as metal/v1/, but main.go puts an extra metal/ in the import path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant