Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and fixes to Swagger Middleware #788

Merged
merged 5 commits into from
Sep 18, 2023
Merged

Refactoring and fixes to Swagger Middleware #788

merged 5 commits into from
Sep 18, 2023

Conversation

gaby
Copy link
Member

@gaby gaby commented Sep 18, 2023

  • Added support for using YAML as Swagger spec. Fixes 🤗 [Question]: swagger yaml support? #708
  • Migrated from fasthttpadapter to fiber/v2/adaptor
  • Added support for Next(), and other missing checks
  • Update documentation
  • Added support for Path and Title
  • Fixed bug where the middleware was reading the Spec and assuming JSON then passing this as Bytes to the go-openapi middleware.
    • Instead now we have a http.HandlerFunc able to serve the SPEC based on extension type back to the middleware
  • Added support for running multiple SwaggerUI's, for example:
// Create Swagger middleware for v1
//
// Swagger will be available at: /api/v1/docs
app.Use(swagger.New(swagger.Config{
    BasePath: "/api/v1/",
    FilePath: "./docs/v1/swagger.json",
    Path:     "docs",
}))

// Create Swagger middleware for v2
//
// Swagger will be available at: /api/v2/docs
app.Use(swagger.New(swagger.Config{
    BasePath: "/api/v2/",
    FilePath: "./docs/v2/swagger.json",
    Path:     "docs",
}))
  • Added extensive unit-tests to verify normal handlers still work.
  • Replaced join.Path with url.JoinPath
  • Use testify.Require() instead of testify.Assert()
  • Added documentation to swagger.Config{}
  • Added example swagger.yaml

Note: I don't consider this PR a breaking change, since the original functionality stayed the same, it's mostly bug fixes and new features.

@gaby gaby added ☢️ Bug Something isn't working ✏️ Feature New feature or request labels Sep 18, 2023
@ReneWerner87

This comment was marked as resolved.

@ReneWerner87 ReneWerner87 merged commit fb703be into main Sep 18, 2023
12 checks passed
@gaby gaby deleted the fix-708 branch September 18, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️ Bug Something isn't working ✏️ Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🤗 [Question]: swagger yaml support?
3 participants