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

Can't have server code in subdirectory #1624

Closed
maqdev opened this issue Jul 18, 2018 · 4 comments · Fixed by #1804
Closed

Can't have server code in subdirectory #1624

maqdev opened this issue Jul 18, 2018 · 4 comments · Fixed by #1804

Comments

@maqdev
Copy link

maqdev commented Jul 18, 2018

Problem statement

When passing -s argument as below which includes /, I was hoping that would allow the server code to be in a subdirectory:

swagger generate server -f ./api/swagger/swagger.yaml -s pkg/srv

However the import statements, for example in configure_srv.go are snake casing the package name:

"github.com/xxx/app/pkg_srv/operations"

Swagger specification

2.0

Environment

swagger version: 0.15.0
go version: 1.10.3
OS: OS-X

@fredbi
Copy link
Contributor

fredbi commented Jul 29, 2018

The generated code is put in a hierarchy of packages which may be customized with the
following options:

      -a, --api-package=                                                          the package to save the operations (default: operations)
      -m, --model-package=                                                        the package to save the models (default: models)
      -s, --server-package=                                                       the package to save the server specific code (default: restapi)
      -c, --client-package=                                                       the package to save the client specific code (default: client)
      -t, --target=                                                               the base directory for generating the files (default: ./)

The organization is determined as follows:

-- {target}
    -- {client-package:-client}
    -- {model-package:-models}
    -- {server-package:-restapi}
       -- {api-package:-operations}
          -- {tags}

You may customize the folder names, but can't specify sub-packages as package names.

@gregmarr
Copy link
Contributor

We fixed this issue for models in December: #1326

@gregmarr
Copy link
Contributor

Commit is here ae57fbc

@maqdev
Copy link
Author

maqdev commented Jul 30, 2018

@fredbi actually you can specify sub-package for the models as mentioned by @gregmarr.
A workaround is to create a sub-directory, then run swagger inside it and it generates correct package names.

@fredbi fredbi self-assigned this Sep 10, 2018
MrLuje added a commit to MrLuje/go-swagger that referenced this issue Nov 9, 2018
MrLuje added a commit to MrLuje/go-swagger that referenced this issue Nov 9, 2018
MrLuje added a commit to MrLuje/go-swagger that referenced this issue Nov 9, 2018
Fixes go-swagger#1624

Signed-off-by: Vincent De Oliveira <ogmniluje@gmail.com>
MrLuje added a commit to MrLuje/go-swagger that referenced this issue Nov 9, 2018
Signed-off-by: Vincent De Oliveira <ogmniluje@gmail.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 17, 2018
Makes generation functional and consistent regarding:
* dashes in names
* reserved suffixes, which are meaningful for go, like 'test'
* sub-directories specified as target names (e.g. 'api/subdir')
* packages for client, model and server

* fixes go-swagger#1683
* fixes go-swagger#1157
* fixes go-swagger#1624

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 17, 2018
Makes generation functional and consistent regarding:
* dashes in names
* reserved suffixes, which are meaningful for go, like 'test'
* sub-directories specified as target names (e.g. 'api/subdir')
* packages for client, model and server

* fixes go-swagger#1683
* fixes go-swagger#1157
* fixes go-swagger#1624

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 18, 2018
Makes generation functional and consistent regarding:
* dashes in names
* reserved suffixes, which are meaningful for go, like 'test'
* sub-directories specified as target names (e.g. 'api/subdir')
* packages for client, model and server

* fixes go-swagger#1683
* fixes go-swagger#1157
* fixes go-swagger#1624

* replaces go-swagger#1790

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 18, 2018
Makes generation functional and consistent regarding:
* dashes in names
* reserved suffixes, which are meaningful for go, like 'test'
* sub-directories specified as target names (e.g. 'api/subdir')
* packages for client, model and server

* fixes go-swagger#1683
* fixes go-swagger#1157
* fixes go-swagger#1624

* replaces go-swagger#1790

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants