Giter Club home page Giter Club logo

go-redoc's Issues

gin response code 404

This is my test demo.

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/mvrilo/go-redoc"
	ginredoc "github.com/mvrilo/go-redoc/gin"
)

func main() {
	doc := redoc.Redoc{
		Title:       "Example API",
		Description: "Example API Description",
		SpecFile:    "./openapi.yml",
		SpecPath:    "/openapi.yml",
		DocsPath:    "/docs",
	}

	r := gin.New()
	r.Use(ginredoc.New(doc))

	println("Documentation served at http://127.0.0.1:8000/docs")
	panic(r.Run(":8000"))
}

When I run and visit http://172.28.73.58:8000/docs Page stuck in initialization (172.28.73.58 is my wsl2 ip)
image
image
And my gin run window has a warning message
[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 404 with 200
Can you tell me how to solve it? thank

net/http not working with mux routers

Registering the net/http handler under a mux router causes a 404 error serving de docs
image

Using the following code:

func RunInternal() error {
	internal := mux.NewRouter()
	internal.HandleFunc("/health", health.GetHealth().Handler)

	doc := redoc.Redoc{
		Title:       "API Docs",
		Description: "API documentation",
		SpecFile:    "./api/openapi-spec/openapi.yaml",
		SpecPath:    "/openapi.yaml",
		DocsPath:    "/docs",
	}

	internal.HandleFunc("/docs", doc.Handler())

	return http.ListenAndServe(":8079", internal)
}

About Echo implementation

Hi, I really like the project @mvrilo but there's some suggestions that I think could improve the project, between these are:

  • The echo example could be updated for something like this:
    image

    The problem with use a middleware for just show documentation is that overwrites all other endpoints.

    image

  • Other things that I'm sure that goes well to the package is the json/yaml tags for the structs, more than nothing because normally the HTTP Servers have configuration files and directly set everything in that configuration file sounds good.

  • Another improvement could be the favicon.ico implementation, in the same way the openapi.yaml is provided in my case.

I don't know if I can open a merge request to make these changes, ready to hear your opinion, me.

load redoc in a path problem

This is example of my code where I try to load the openapi spec in a certain path. Code is not compiled its just
to show how I did it.

Client struct {
    Router *mux.Router
}

client := &Client{}

doc := redoc.Redoc{
	Title:       "",
	Description: "",
	SpecFile:    "./api.yaml",
	SpecPath:    "/api.yaml",
        DocsPath:    "/docs",
}


client.Router.HandleFunc("/hello",HelloHandlerFunc).Methods(http.MethodGet)
client.Router.HandleFunc("/openapi",doc.Handler).Methods(http.MethodGet)

I am trying to access the docs through http://localhost:port/openapi/docs without luck. It just return blank white page

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.