Echo: generate Unimplemented implementation#631
Closed
urso wants to merge 1 commit intooapi-codegen:mainfrom
Closed
Echo: generate Unimplemented implementation#631urso wants to merge 1 commit intooapi-codegen:mainfrom
Unimplemented implementation#631urso wants to merge 1 commit intooapi-codegen:mainfrom
Conversation
jamietanna
reviewed
Oct 24, 2022
jamietanna
reviewed
Sep 2, 2023
| type Unimplemented struct {} | ||
| {{range .}}{{.SummaryAsComment }} | ||
| // ({{.Method}} {{.Path}}) | ||
| func (_ Unimplemented) {{.OperationId}}(ctx echo.Context{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}) error { |
Member
There was a problem hiding this comment.
Suggested change
| func (_ Unimplemented) {{.OperationId}}(ctx echo.Context{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}) error { | |
| func (Unimplemented) {{.OperationId}}(ctx echo.Context{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}) error { |
Update echo-interface.tmpl to generate an implementation for
ServerInterface that always returns a 404.
The `Unimplemented` server can be used like this (assuming the code is
generated in package `spec`):
```
type MyAPIServer struct {
spec.Unimplemented
}
...
```
Using `Unimplemented` is optional, but might help when prototyping APIs
or in case the OpenAPI spec is managed in a separate repo and mutliple
developers.
grpc-go uses a similar strategy. For example see the
[examples/route_guide/server/server.go](https://github.com/grpc/grpc-go/blob/master/examples/route_guide/server/server.go#L57)
file.
c2d3f4e to
d383841
Compare
Member
|
Thank you for contributing, and I'm very sorry for taking so long to get to this PR. At this point, the code has changed so much that it's no longer relevant because the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update echo-interface.tmpl to generate an implementation for ServerInterface that always returns a 404.
The
Unimplementedserver can be used like this (assuming the code is generated in packagespec):Using
Unimplementedis optional, but might help when prototyping APIs or in case the OpenAPI spec is managed in a separate repo and mutliple developers.grpc-go uses a similar strategy. For example see the examples/route_guide/server/server.go file.