Skip to content

feat: more options for UI middleware#278

Merged
fredbi merged 1 commit intogo-openapi:masterfrom
fredbi:feat/doc-middleware-options
Dec 12, 2023
Merged

feat: more options for UI middleware#278
fredbi merged 1 commit intogo-openapi:masterfrom
fredbi:feat/doc-middleware-options

Conversation

@fredbi
Copy link
Copy Markdown
Member

@fredbi fredbi commented Dec 11, 2023

  • refactored UI middleware

    • factorized UI middleware to remove duplicated code
    • factorized UI middleware options: to avoid breaking changes in the options types, there is a decode/encode to a common structure
    • added more options:
      • allows to fully customize the UI template
    • added more unit tests
  • Spec middleware: added support for optional SpecOption argument

    • allows to serve the spec from a custom path / document name
  • serving with or without trailing "/" (cf. issue Swagger Middleware drops trailing slash and can't find path #238)

    • replaced path.Join() by path.Clean(), which is the intended behavior (i.e. serve the path, irrespective of the presence of a trailing slash)
    • generalized this behavior to all UI and Spec middleware, not just swaggerUI
  • API Context:

    • exposed middleware to serve RapiDoc UI
    • allowed new UIOption (...UIOption) to the APIHandler, etc middleware
    • coordinated UI / Spec middleware to be consistent when non-default path/document URL is served

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (248b38c) 80.83% compared to head (f3145ae) 82.04%.

Files Patch % Lines
middleware/ui_options.go 85.00% 8 Missing and 4 partials ⚠️
middleware/context.go 95.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #278      +/-   ##
==========================================
+ Coverage   80.83%   82.04%   +1.20%     
==========================================
  Files          44       45       +1     
  Lines        3366     3420      +54     
==========================================
+ Hits         2721     2806      +85     
+ Misses        535      501      -34     
- Partials      110      113       +3     
Flag Coverage Δ
oldstable 82.04% <92.89%> (+1.20%) ⬆️
stable 82.04% <92.89%> (+1.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- refactored UI middleware
  * factorized chore middleware to remove duplicated code
  * factorized UI middleware options: to avoid breaking changes in the
    options types, there is a decode/encode to a common structure
  * added more options:
    * allows to fully customize the UI template
  * added more unit tests

- Spec middleware: added support for optional SpecOption argument
  * allows to serve the spec from a custom path / document name

- serving with or without trailing "/" (cf. issue go-openapi#238)
  * replaced path.Join() by path.Clean(), which is the intended behavior
    (i.e. serve the path, irrespective of the presence of a trailing
    slash)
  * generalized this behavior to all UI and Spec middleware, not just
    swaggerUI

- API Context:
  * exposed middleware to serve RapiDoc UI
  * allowed new UIOption (...UIOption) to the APIHandler, etc middleware
  * coordinated UI / Spec middleware to be consistent when non-default
    path/document URL is served

* fixes go-openapi#192
* fixes go-openapi#226

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi force-pushed the feat/doc-middleware-options branch from a4550bc to f3145ae Compare December 11, 2023 22:00
@fredbi fredbi merged commit fe71d27 into go-openapi:master Dec 12, 2023
@fredbi fredbi deleted the feat/doc-middleware-options branch December 12, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReDoc uses unmodifiable spec path add the possibilty to use a custom swagger ui template

2 participants