Giter VIP home page Giter VIP logo

yaag's Issues

cannot use irisyaag.New()

cannot use irisyaag.New() (type "github.com/kataras/iris/context".Handler) as type "github.com/kataras/iris/v12/context".Handler in argument to api.APIBuilder.Use

Documentations for 3xx and 4xx is needed.

Hi,

I have been using yagg for generating the API documentation. I found API are generating only for success cases. I have found this piece of code. Here you are allowing only for status codes ranges in 2XX.

func IsStatusCodeValid(code int) bool  {
	if code >= 200 && code < 300 {
		return true
	} else {
		return false
	}
}

please rewrite it to allow 3xx and 4xx

Importing gin-gonic/gin.v1

I import the versioned gin framework and its causing I think its causing problems. Any ideas on how to fix?

cannot use "github.com/betacraft/yaag/gin".Document() (type "github.com/gin-gonic/gin".HandlerFunc) as type "placeable.com/audit-service/vendor/gopkg.in/gin-gonic/gin.v1".HandlerFunc in argument to r.Use

Why not follow Swagger standard?

Can yaag configure to follow Swagger/OpenAPI standard as it can import by Postman and do automated testing?

Can anyone recommend an existing solution?

Help with Negroni / Gorilla Mux combination

Can anyone help getting Yaag to work with Negroni and Gorilla Mux? No matter what I try I seem to get nothing or I get mulitple http write errors probably because because I already have routes.

I have tried this and a few other things ...
`
yaag.Init(&yaag.Config{On: true, DocTitle: "Negroni-gorilla", DocPath: "apidoc.html", BaseUrls: map[string]string{"Production": "", "Staging": ""}})

router := mux.NewRouter()
// ... Add a bunch of routes
router.HandleFunc("/", middleware.HandleFunc(handler)) //this does nothing
n := negroni.Classic()
n.Use(c)
//n.UseHandlerFunc(middleware.HandleFunc(handler)) //this gives an error but makes a doc
n.UseHandler(router)
n.Run(":5000")

func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, time.Now().String())

}

`

Update:
I got "n.UseHandlerFunc(middleware.HandleFunc(handler))" to work by removing
"fmt.Fprintf(w, time.Now().String())" from the handler. It looks like once I write a response it finishes.
Not sure if that is really working or not.
I still don't get responses. Just requests.

Another_ question (if the first question can be solved):
All the examples show just returning time. How do you return the actual response?
Maybe this would become more apparent if this was working for me. But it seems like all the handlers just return time. Help my Ignorance. Are the responses generated in the middleware somehow?
I know we could return something else in the handler but I don't see how to return a response.

Adding native support for bmizerany/pat (Sinatra style pattern muxer)

How much work would it be to add native support for https://github.com/bmizerany/pat (a Sinatra style pattern muxer)? It's built purely on "net/http" and "net/url", so there might be a workaround that leverages the basic net.http package (https://github.com/betacraft/yaag#how-to-use-with-basic-nethttp-package), but I figured I would ask about native support.

By the way, thank you for creating this project! This sort of middleware-based api doc generation is extremely useful for large projects with constantly evolving handlers.

Add support for editing API other fields

First of all, it is really convenient to generate api documents in this way, there is really no pain. But there are some limitations.

For example, API description, param description cannot be customized.

If you can continue to edit the api description and parameter description in the generated html file, then this tool can be safely used in many project

some idea:

  • Integration with other online document editing services
  • Adapt the generated data to tools such as swagger or apidoc

not able to use it with gin !

cannot use "github.com/betacraft/yaag/gin".Document() (type "gopkg.in/gin-gonic/gin.v1".HandlerFunc) as type "github.com/gin-gonic/gin".HandlerFunc in argument to router.Use

Allow for configurable template

If you're exposing API docs to third parties, you probably want the ability to have the docs at least somewhat match the look and feel of the rest of your site.

cpu, Memory usage spike when endpoints returns a large json file

We got cpu, memory and file descriptors spikes when the endpoint returns a large json object. pprof shows most of them are spent on yaag/yaag.GenerateHtml and yaag/yaag.Init. Down the tree it, it calls encoding/json.Mashal (47%) and html/template.htmlReplacer(34%) which calls runtime.slicebytetostring(16%) and bytes.(*Buffer).WriteString.

The memory doesn't get GC-ed quickly.

func generateHtml can't work

func Init(conf *Config) {
	config = conf
	// load the config file
	if conf.DocPath == "" {
		conf.DocPath = "apidoc.html"
	}


	filePath, err := filepath.Abs(conf.DocPath + ".json")
	dataFile, err := os.Open(filePath)
	defer dataFile.Close()
	if err == nil {
		json.NewDecoder(io.Reader(dataFile)).Decode(spec)
		generateHtml()
	}
} 

when init , filePath does not exist os.Open() will be error

err != nil

generateHtml don‘t work always

how do i generateHtml

thanks

application/x-www-form-urlencoded 参数为空时报错

application/x-www-form-urlencoded 参数为空时报错

INFO] 2019/09/08 12:16 200 3.582027ms 127.0.0.1 POST /m/login
12:18:23 app | 2019/09/08 12:18:23 application/x-www-form-urlencoded
12:18:23 app | 2019/09/08 12:18:23 Reading form
12:18:23 app | [WARN] 2019/09/08 12:18 Recovered from a route's Handler('github.com/betacraft/yaag/irisyaag.New.func1')
At Request: 200 /m/login POST 127.0.0.1
Trace: runtime error: index out of range

/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:522
/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:44
/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:139
/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:83
/Users/xxx/go/src/github.com/betacraft/yaag/irisyaag/middleware.go:23

/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:139
func ReadPostForm(req *http.Request) map[string]string {
postForm := map[string]string{}
for _, param := range strings.Split(*ReadBody(req), "&") {
value := strings.Split(param, "=")
postForm[value[0]] = value[1]
}
return postForm
}

加粗这一行,很明显没有判断空参数的情况。

hi,I have a problem with "go mod" .

require github.com/betacraft/yaag/yaag: version "v0.0.0-20191027021412-565f65e36090" invalid: missing github.com/betacraft/yaag/yaag/go.mod at revision 565f65e

go.mod:

github.com/betacraft/yaag/yaag master

I'm not getting any output

I've initialised the library...

yaag.Init(&yaag.Config{
        On:       true,
        DocTitle: "Gin",
        DocPath:  "apidoc.html",
        BaseUrls: map[string]string{"Production": "http://api.test.com", "Staging": "http://devapi.test.com"},
    })

But I'm not getting any output, no apidoc.html file's being recreated etc

Am I missing something?

Cheers!

websocket: response does not implement http.Hijacker

Getting an error when I use websockets with yaag middleware.

func echo(w http.ResponseWriter, r *http.Request) {
	c, err := upgrader.Upgrade(w, r, nil)
	hErr(err, "upgrade err")
	defer c.Close()
	for {
		// c.ReadJSON()
		mt, message, err := c.ReadMessage()
		hErr(err, "readMessage")
		hErr(c.WriteMessage(mt, message), "write err")
	}
}

The error happens at the upgrader.Upgrade() call

Handle multipart/form-data POSTs

When I post multipart/form-data, Yaag doesn't give me the form data. I think we should ignore the file data, but parse the data and show it for simpler documentation.

For example, this post had json data included with it:
screenshot 2016-01-26 at 10 14 36 am

Thanks!

can I add extra information with annotations?

I would like to add additional information to the template using some annotations over the functions handlers, something like

@Description  This endpoint to get all the users in the app
@return json
@... 
func getAllUsers(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

And handle the route

r.GET("/api/v1/users/all", getAllUsers) 

And generate something like

This endpoint to get all the users in the app
GET: /api/v1/users/all

can I do that?

Request body is not considered while generating document in unit test mode.

I have integrated yaag with iris application, when this app is run in production or live server then the Post Request body is considered and included in generated document. But when we run unit tests with httptest then Request Body is ignored in generated documents.

The below pull request is required to test this.
#34

Implementing yaag into existing project

I currently have a moderately sized API that is in ongoing development and I came across your "yaag" project and thought I would give it a whirl. I checked out our martini branch and started implementing as your README.md dictates.

I made sure to import the two yaag libraries: yaag/yaag and yaag/martiniyaag

Added: m.Use(martiniyaag.Document)

I now have so many damn m.Use statements it is getting out of control ;)

That seems to be all that is necessary other than initiating the config option in my main(), which I did as well. Do you know if utilizing route groups with Martini would prevent this from working as expected? Currently I leverage m.Group() for all of our routes.

yaag sometimes it doesn't work

When I request the server,sometimes yaag add the api info to apidoc.html,but sometines it doesn't work;
My computer environment is windows

Vet issues

Running go vet:

akshay@storm:$ go vet github.com/betacraft/yaag/yaag
../../github.com/betacraft/yaag/yaag/yaag.go:111: unreachable code
../../github.com/betacraft/yaag/yaag/yaag.go:117: unreachable code
exit status 1

Hangs when I run `go get`

There seems to be a 404 when I run go get using

yaag_gin "github.com/betacraft/yaag/gin"
    "github.com/betacraft/yaag/yaag"

Use the wrong repo path in readme file

The repo path should be :

"github.com/RainingClouds/yaag/martiniyaag"
"github.com/RainingClouds/yaag/yaag"

But the below path appear in readme file:

Import github.com/gophergala/yaag/yaag
Import github.com/gophergala/yaag/martiniyaag

Cannot install the package

I have the following errors when I execute go get github.com/betacraft/yaag/..

#github.com/betacraft/yaag/filters
../github.com/betacraft/yaag/filters/filter.go:24:32: cannot use w (type *httptest.ResponseRecorder) as type revel.ServerResponse in argument to revel.NewResponse:
*httptest.ResponseRecorder does not implement revel.ServerResponse (missing Get method)
../github.com/betacraft/yaag/filters/filter.go:30:22: c.Request.Request undefined (type *revel.Request has no field or method Request)
../github.com/betacraft/yaag/filters/filter.go:35:39: c.Request.Request undefined (type *revel.Request has no field or method Request)
../github.com/betacraft/yaag/filters/filter.go:81:14: cannot range over c.Request.Header (type *revel.RevelHeader)

I'm using go version go1.9.2 darwin/amd64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.