Skip to content

Form Data Option Types not serialized properly #214

Open
@rametta

Description

@rametta

Description

When calling a request that specifies FormData as the type and has fields that can be Option types, when specifying a value like Some true or Some 6 it is actually sending the whole option as a string to the API like Some(true) and Some(6) instead of just true or 6.

Example

let formData = MyProvider.OperationTypes.UpdateItem_formData()
formData.Name <- "My name"
formData.SomeFieldThatExpectsABool <- Some true
formData.SomeFieldThatExpectsANumber <- Some 6
let! res = client.UpdateItem(formData)

Intrestingly, it works as expected when specifying the Provider like this OpenApiClientProvider<Schema, PreferNullable=true> (with PreferNullable) but then I have to use Nullable true or Nullable 6 and it'll send to API as expected, but with Option types it does not.

This is on version 2.0.0-beta6

Repro steps

  1. Have a provider that needs a form data request and field that exposes as an Option
  2. Set the value of the Option to something like Some 6 or whatever the option type needs
  3. See the backend receive the value as Some(6) instead of just 6

Expected behavior

The option type value should be unwrapped before sending to API if it's Some and should be null if None

Actual behavior

The option type value is not unwrapped before sending to API

Known workarounds

Use PreferNullable=true instead, that works

Affected Type Providers

  • SwaggerClientProvider
  • OpenApiClientProvider (I only tested with this one)

Related information

  • Operating system Mac OS Montery
  • Branch
  • .NET Runtime, CoreCLR or Mono Version net6.0
  • Performance information, links to performance testing scripts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions