-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework module to be generic for any documentation tool
- Loading branch information
1 parent
e38d83a
commit afb96a2
Showing
15 changed files
with
2,236 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using GenHTTP.Modules.ApiBrowsing.Common; | ||
using GenHTTP.Modules.Layouting.Provider; | ||
|
||
namespace GenHTTP.Modules.ApiBrowsing; | ||
|
||
public static class ApiBrowser | ||
{ | ||
|
||
#region Factories | ||
|
||
public static BrowserHandlerBuilder SwaggerUI() => new("Swagger"); | ||
|
||
public static BrowserHandlerBuilder Redoc() => new("Redoc"); | ||
|
||
#endregion | ||
|
||
#region Layout extensions | ||
|
||
public static LayoutBuilder AddSwaggerUI(this LayoutBuilder layout, string segment = "swagger", string? url = null) | ||
=> AddBrowser(layout, SwaggerUI(), segment, url); | ||
|
||
public static LayoutBuilder AddRedoc(this LayoutBuilder layout, string segment = "redoc", string? url = null) | ||
=> AddBrowser(layout, Redoc(), segment, url); | ||
|
||
private static LayoutBuilder AddBrowser(this LayoutBuilder layout, BrowserHandlerBuilder builder, string segment, string? url) | ||
{ | ||
if (url != null) | ||
{ | ||
builder.Url(url); | ||
} | ||
|
||
return layout.Add(segment, builder); | ||
} | ||
|
||
#endregion | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using GenHTTP.Api.Content; | ||
|
||
namespace GenHTTP.Modules.ApiBrowsing.Common; | ||
|
||
public class BrowserHandlerBuilder(string resourceRoot) : IHandlerBuilder<BrowserHandlerBuilder> | ||
{ | ||
private readonly List<IConcernBuilder> _Concerns = []; | ||
|
||
private string? _Url; | ||
|
||
public BrowserHandlerBuilder Url(string url) | ||
{ | ||
_Url = url; | ||
return this; | ||
} | ||
|
||
public BrowserHandlerBuilder Add(IConcernBuilder concern) | ||
{ | ||
_Concerns.Add(concern); | ||
return this; | ||
} | ||
|
||
public IHandler Build() => Concerns.Chain(_Concerns, new BrowserHandler(resourceRoot, _Url)); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Redoc</title> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="./static/roboto.css" rel="stylesheet"> | ||
|
||
<style> | ||
body \{ | ||
margin: 0; | ||
padding: 0; | ||
\} | ||
</style> | ||
</head> | ||
<body> | ||
<redoc spec-url='{url}'></redoc> | ||
<script src="./static/redoc-standalone.js"> </script> | ||
</body> | ||
</html> |
1,826 changes: 1,826 additions & 0 deletions
1,826
Modules/ApiBrowsing/Redoc/Static/redoc-standalone.js
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.