Comments (5)
With current approach this is not possible. We generate route information at runtime, and type/function comments are not accessible at runtime.
from yaag.
One possibility is something like adding an http header that is interpreted and then removed by the yaag middleware. Not super elegant, but would do the trick. Could even have a utility function to add it with a function call or something. Still wouldn't be an annotation though. Thoughts @aniketawati?
from yaag.
@cristianchaparroa - Implemented a quick possible solution here, check out examples/core/server.go for the usage. Not quite an annotation, but works fairly similarly.
@aniketawati - not sure what you think of something like this, it is a bit of a stretch of the original usage, but it's kind of nice to have as a feature. This is just an MVP but I wanted to let you take a look before I did too much more.
from yaag.
@BrianNewsom adding annotations in code won't be a good idea. We don't want any of this code to run in production. Every handler calling annotations package methods even when yaag is not ON, would be an overhead if you consider large loads.
Better way for implementing this would be to take the source path as a parameter in Yaag init. Get a list of handler packages in yaag init. Use https://godoc.org/go/doc to generate godoc in memory for the packages. In middleware, loop through next functions, and find their package/names through reflection, and get corresponding comments through godoc.
from yaag.
I have added a preliminary implementation for this in a feature branch - feature/annotations.
The annotations could go into a metadata object in Spec. While processing spec client can relate ApiCall path to Metadata and generate docs.
This is a generated sample -
{
"ApiSpecs": null,
"MetaData": [
{
"Path": "/",
"Description": "This is a dummy handler",
"Custom": null
},
{
"Path": "/say_it",
"Description": "This is a dummy post handler",
"Custom": null
}
]
}
Run example in examples/core/ to see this in action.
from yaag.
Related Issues (20)
- not able to use it with gin !
- Using Core example no apidoc.html create
- Help with Negroni / Gorilla Mux combination HOT 2
- websocket: response does not implement http.Hijacker
- yaag sometimes it doesn't work
- Cannot install the package
- Adding native support for bmizerany/pat (Sinatra style pattern muxer)
- Documentations for 3xx and 4xx is needed.
- Why not follow Swagger standard?
- Iris dependency is limited to 1.11 and cannot be supported for new versions? HOT 1
- application/x-www-form-urlencoded 参数为空时报错
- cannot use irisyaag.New() HOT 3
- go get yaag 404 NOT FOUND HOT 1
- 如何过滤掉指定的请求路径
- Add Swagger Support
- func generateHtml can't work
- hi,I have a problem with "go mod" . HOT 1
- maybe version trouble
- Add support for editing API other fields
- Why not display response body HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaag.