Skip to content

Auspice-Capital/FSharp.SystemTextJson.Swagger

 
 

Repository files navigation

FSharp.SystemTextJson.Swagger

Swagger settings for FSharp.SystemTextJson. Still experimantal

Usage

Only replace AddSwaggerGen with AddSwaggerForSystemTextJson

let builder =  WebApplication.CreateBuilder(args)
let fsOptions = JsonFSharpOptions() // setup options here 
//setup usage of JsonFSharpConverter                
builder.Services.AddControllers()
                    .AddJsonOptions(fun opts ->
                        opts.JsonSerializerOptions.Converters.Add(JsonFSharpConverter(fsOptions))) 
// setup usage of SwaggerForSystemTextJson - use instead AddSwaggerGen 
builder.Services.AddSwaggerForSystemTextJson(fsOptions)
        
let app = builder.Build()
        
if (app.Environment.IsDevelopment()) then
      app.UseSwagger() |> ignore
      app.UseSwaggerUI() |> ignore

What works

Not everything is now implemented. Some things works with limitations

Records

  • Works
  • All properties are required except of Skippable
  • Option properties are set as nullable

Tuples

  • Works
  • Evaluates to array of composed type
  • Array has length limits to tuple length
  • Composed type is made as oneOf keyType and valueType
  • Warning - request generated by this schema could be invalid.

Collections

  • List and Set: works
  • Maps
    • with string keys - works
    • with boxed string - works
    • other - works
      • Evaluates to array of Tuples.
      • Warning - request generated by this schema could be invalid

Unions

  • Almost every setup combinations works
  • Still experimental

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • F# 100.0%