Tarmil / FSharp.SystemTextJson

System.Text.Json extensions for F# types
MIT License
329 stars 45 forks source link

Getting Swagger/OpenAPI schemas to show up correctly #104

Open reinux opened 2 years ago

reinux commented 2 years ago

This might be a bit of an ask, but is there a chance we can get the Swagger APIs to show up for this correctly?

Currently, unions show up like:


// F#
type InvoiceIndexItem = {
  Id: InvoiceId
  InvoiceNumber: string
  Principal: PrincipalSummary
  Subtotal: decimal
  TotalAmount: decimal
}

// Json

[
  {
    "Id": {
      "Tag": 0,
      "Item": 0
    },
    "InvoiceNumber": "string",
    "Principal": {
      "id": {
        "Tag": 0,
        "Item": 0
      },
      "name": "string"
    },
    "Subtotal": 0,
    "TotalAmount": 0
  }
]
Tarmil commented 2 years ago

It is indeed a significant amount of work, but I have some experimentation that I started on this topic some time ago. I'll need to pick that up again.

reinux commented 2 years ago

Have you had a chance to look at this at all?

Would be cool to be able to use Swagger with F# for work.

Edit: Exploring some code to see if there's anything I can contribute. It looks like NSwag is a lot more straightforward than Swashbuckle.

kaaja-h commented 1 year ago

I prepared FSharp.SystemTextJson.Swagger for swagger work with FSharp.SystemTextJson. Still lot of work to do. Especialy on union types. Please report issues and be free to send pull requests.

Tarmil commented 1 year ago

@kaaja-h Awesome, thanks! I'll be sure to check it out.

reinux commented 1 year ago

Thanks @kaaja-h!

C0DK commented 1 year ago

@kaaja-h awesome project! I hope you'll continue supporting it. if there is something somewhat trivial to do to help, please say so :)