intellifactory / sitelets Goto Github PK
View Code? Open in Web Editor NEWSitelets for ASP.NET Core
Sitelets for ASP.NET Core
Using Sitelet
's Endpoint
's type it's possible to generate an OpenAPI
documentation for simple cases. The documentation for OpenAPI
documentation can be found here. With SwaggerUI it's possible to provide a documentation endpoint and offer test calls against the API.
.UseOpenApi(endpointsType: Type, config: OpenApiIntegration.GenerateOpenApiConfig)
is an extension method on IEndpointRouteBuilder
, which configures the site to route /swagger.json
calls to provide the generated OpenAPI
documentation for the user.
type GenerateOpenApiConfig = {
Version: string
Title: string
ServerUrls: string []
SerializerOptions: JsonSerializerOptions
}
config contains the required Info Object's Version
and Title
fields, ServerUrls
and JsonSerializerOptions
for ISerializerDataContractResolver. JsonSerializerOptions
requires https://github.com/Tarmil/FSharp.SystemTextJson.
To set up SwaggerUI
.UseSwaggerUI
needs to point to /swagger.json
.
Example code on an IApplicationBuilder
to setup /swagger
endpoint for SwaggerUI
open System.Text.Json
open System.Text.Json.Serialization
open Microsoft.AspNetCore.Builder
...
let servers = [| "http://localhost:5000"; "https://localhost:5001" |]
let serializerOptions =
let options = JsonSerializerOptions (PropertyNamingPolicy=JsonNamingPolicy.CamelCase)
options.Converters.Add( JsonStringEnumConverter())
options.Converters.Add(
JsonFSharpConverter(
JsonUnionEncoding.ExternalTag
||| JsonUnionEncoding.NamedFields
||| JsonUnionEncoding.UnwrapFieldlessTags
||| JsonUnionEncoding.UnwrapOption))
options
...
app
.UseRouting()
.UseEndpoints(fun e ->
e.UseOpenApi(typeof<MyEndpoint>, {
Version = "1.0.0.0"
Title = "Title"
ServerUrls = servers
SerializerOptions = serializerOptions
}))
.UseSwaggerUI(fun c -> c.SwaggerEndpoint("/swagger.json", "My API V1"))
...
Documentation generation is restricted to an Endpoint
type of Discriminated Union, with primitive system type union fields. int
, float
, string
.
Example Endpoint
type:
type Endpoint =
| [<EndPoint "GET /echo">] Data of msg:string * value:int
| [<EndPoint "GET /actionresult">] ActionResult
| [<EndPoint "GET /task/str">] Task1
| [<EndPoint "GET /task/actionresult">] Task2
| [<EndPoint "GET /task/enumerable">] Task3
| [<EndPoint "GET /enum">] Enumerable1
| [<EndPoint "GET /enum/async">] Enumerable2
| Test1
| Test2
Where no annotation defines the Operation (for example Get
/Post
), the default is Get
.
Parameter name defaults to it's Type
's .Name
.
Link function needs to be mapped during Sitelet operations, so we need to extend Context to include a Link function to match original design for https://github.com/dotnet-websharper/core
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.