main.go skeleton for gorilla mux generated code #2326
-
|
Hi, I made a dive in using the go generator for a pretty substantial oas 3.0.3 file. The generation is flawless (error free) but have run into a problem. First to ensure I understand things a bit, I reverted back tot the ping pong example file on this site and got this to work with the example code supplied. However this is a case with a "plain" ServerInterface while I have generated (and would like to use) my code with strictServerInterface (the code is there in the file generated). The main.go example (for ServerInterface) listed uses a : // get an |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
This sounds like a Go usage question. Could you perhaps provide a minimal snippet to demonstrate the problem? I'm not quite understanding your question. |
Beta Was this translation helpful? Give feedback.
-
|
We have an example here (https://github.com/oapi-codegen/oapi-codegen/tree/main/examples/petstore-expanded/strict), which shows how to build the canonical OpenAPI pet store example on top of a strict-server with the Chi framework as its underlying server. The main looks like this: A "strict server" is a wrapper around The magic happens here, when you create a You then pass that |
Beta Was this translation helpful? Give feedback.
-
|
It's going to be the same exact pattern, almost line for line. I just wanted to show you how it's wired together. The underlying server type doesn't matter, because StrictServer is a wrapper around any of them (since it just adapts around ServerInterface). It's really backend agnostic. |
Beta Was this translation helpful? Give feedback.
We have an example here (https://github.com/oapi-codegen/oapi-codegen/tree/main/examples/petstore-expanded/strict), which shows how to build the canonical OpenAPI pet store example on top of a strict-server with the Chi framework as its underlying server.
The main looks like this:
https://github.com/oapi-codegen/oapi-codegen/blob/main/examples/petstore-expanded/strict/petstore.go#L20
A "strict server" is a wrapper around
ServerInterface, which performs additional marshaling and validation to make your job easier, so you only need to implement theStrictServerInterface.The magic happens here, when you create a
StrictServer, it returns to you aServerInterface:https://github.com/oapi-code…