-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How do I convince dep to get go-swagger/generator/templates, which contains no Go files? #2308
Comments
@mdelvecchio-wasabi you don't need to fork. You can use the regular go-swagger and configure your template set (well, some are locked but there is an override to that as well) with `swagger generate server --config-file my-config.yaml. There is some doc here: https://goswagger.io/use/template_layout.html Here is an example that I used for some pet project some time ago (the config hasn't changed). As you can see, I had overridden almost everything but the models. #
# The go-swagger custom templates configuration to generate chaincode skeletons
#
layout:
application:
- name: configure
# Generates configure_api.go.
# This is a modified bersion of the standard version, with
# automatic registration of API operations handlers and
# custom OAuth2 authorization method.
source: asset:serverConfigureapi
target: "{{ joinFilePath .Target .ServerPackage }}"
file_name: "configure_{{ .Name }}.go"
# Set to false now that our template links to implem
skip_exists: false
skip_format: false
# Generates main for server [disabled]
- name: main
source: asset:serverMain
target: "{{ joinFilePath .Target \"cmd\" (dasherize (pascalize .Name)) }}-server"
file_name: "main.go"
# Generates embedded spec
- name: embedded_spec
source: asset:swaggerJsonEmbed
target: "{{ joinFilePath .Target .ServerPackage }}"
file_name: "embedded_spec.go"
# Generates server
- name: server
source: asset:serverServer
target: "{{ joinFilePath .Target .ServerPackage }}"
file_name: "server.go"
# Generates xxx_api.go (standard template).
- name: builder
source: asset:serverBuilder
target: "{{ joinFilePath .Target .ServerPackage .Package }}"
file_name: "{{ snakize (pascalize .Name) }}_api.go"
# Generates doc server. This is a stripped down version of the standard
# server, with an interface to allow for composition
- name: doc
source: asset:serverDoc
target: "{{ joinFilePath .Target .ServerPackage }}"
file_name: "doc.go"
# Generates common methods for implementation package [specific]
- name: implementation_common
source: server/implementation_common.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_common.go"
skip_exists: false
skip_format: false
# Unit test for common methods for implementation package [specific]
- name: implementation_common_test
source: server/implementation_common_test.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_common_test.go"
skip_exists: false
skip_format: false
# Generates responders for implementation package [specific]
- name: implementation_responder
source: server/implementation_responder.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_responder.go"
skip_exists: false
skip_format: false
- name: implementation_responder_test
source: server/implementation_responder_test.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_responder_test.go"
skip_exists: false
skip_format: false
- name: implementation_parameter_test
source: server/implementation_parameter_test.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_parameter_test.go"
skip_exists: false
skip_format: false
- name: implementation_gen_fixtures
source: server/gen_fixtures.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "gen_fixtures.sh"
skip_exists: false
skip_format: true
models:
- name: definition
source: asset:model
target: "{{ joinFilePath .Target .ModelPackage }}"
file_name: "{{ (snakize (pascalize .Name)) }}.go"
operations:
- name: parameters
source: asset:serverParameter
target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}"
file_name: "{{ (snakize (pascalize .Name)) }}_parameters.go"
- name: responses
source: asset:serverResponses
target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}"
file_name: "{{ (snakize (pascalize .Name)) }}_responses.go"
- name: handler
source: asset:serverOperation
target: "{{ if gt (len .Tags) 0 }}{{ joinFilePath .Target .ServerPackage .APIPackage .Package }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}"
file_name: "{{ (snakize (pascalize .Name)) }}.go"
operation_groups:
# Generates API skeleton methods for implementation package [specific]
- name: implementation_groups
source: server/implementation_groups.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ snakize (pascalize .Name) }}.go"
skip_exists: false
skip_format: false
- name: implementation_groups_test
source: server/implementation_groups_test.gotmpl
target: "{{ joinFilePath .Target \"implementation\" }}"
file_name: "implementation_{{ (snakize (pascalize .Name)) }}_test.go"
skip_exists: false
skip_format: false |
Problem statement
I have forked go-swagger/go-swagger in order to customize the templates used to generate the server. I can't convince dep to check out the go-swagger/generator/templates directory (and subdirectories) into my vendor directory, because it contains no Go files.
I have added this to my Gopkg.toml file:
But when I run "dep ensure", I get this error:
What is the best way to add the templates to my git repository?
Thanks.
The text was updated successfully, but these errors were encountered: