Closed
Description
Steps you follow to reproduce the error:
- I start with a working REST API and with properly generating Swagger definitions
- I added a 'base_path' attribute to the 'openapiv2_swagger' annotation in my proto file
- I removed the equivalent base_path prefix from each 'google.api.http' annotation (base_path = "/api/v1")
- I regenerated my Go code and restarted my API
- All my REST APIs now return 404 errors
What did you expect to happen instead:
I expected the API to remain working
What's your theory on why it isn't working:
The generated code was previously generating this:
pattern_Provider_EncryptClientSecret_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "provider", "client_secret_encrypter"}, ""))
It is now generating this:
pattern_Provider_EncryptClientSecret_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"provider", "client_secret_encrypter"}, ""))
It seems like the generator is not aware of the 'base_path' attribute and expects the 'google.api.http' to hold the entire path. However, adding this path back on (while retaining 'base_path' attribute) has the impact of:
- Adding that path to all endpoints displayed in the Swagger UI which makes it very 'noisy' and hard to read
- Breaking the Swagger UI "try it out" feature which doubles up the 'base_path' be prefixing base_path to all operations