project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

.go files generated from swagger.yml

Open m15ch4 opened this issue 5 years ago • 1 comments

What is a common approach when building API Server from swagger spec file (usually swagger.yml). Command swagger generate server... generates a bunch of .go files. Where those generated .go files should be placed. Is a good approach to put them to /pkg/api/ ?

m15ch4 avatar Nov 05 '19 21:11 m15ch4

I'd recommend to keep them under /api/, in same subdirectory which contains swagger.yml - because it makes sense to consider both swagger.yml and generated files "a same thing" (at least if you're not going to manually change autogenerated files, which is bad practice anyway).

But if you will manually change autogenerated files, then, yeah, put them under either internal/ or pkg/.

powerman avatar Sep 07 '20 08:09 powerman