Skip to content

Type of TimeSpan incorrectly inferred as complex object instead of string #401

@basilfx

Description

@basilfx

Describe the issue
The type that is inferred for a TimeSpan is a complex object. Instead, I would expect a string (something like 1.00:00:00).

A simple HttpTrigger that returns an OkObjectResult serializes a TimeSpan to a string, whereas the extension resolves a complex object for its schema definition. If I am correct, the OkObjectResult uses the Newtonsoft.Json serializer.

I tried to 'override' it using a JsonConverter attribute, but that does not work. Neither does adding [DataType(DataType.Duration)].

To Reproduce
See this demonstration project: https://github.com/basilfx/azure-functions-openapi-function-timespan

Expected behavior
TimeSpan schema type is inferred as a string.

Screenshots
Note how the result is different from the example schema.

Schermafbeelding 2022-03-23 om 22 28 54

Schermafbeelding 2022-03-23 om 22 46 27

Environment (please complete the following information, if applicable):

  • OS: macOS
  • Azure Functions v4
  • .NET SDK 6.0.102
  • OpenAPI Extension 1.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions