microsoft / kiota-typescript

TypeScript libraries for Kiota-generated API clients.
https://aka.ms/kiota/docs
MIT License
32 stars 25 forks source link

Conflict on DateOnly when swagger file defines a DateOnly type #1186

Closed mbursill closed 1 month ago

mbursill commented 1 month ago

Generated code for a model that includes a DateOnly type (from C#) is including the following fields:

    /**
     * The dayNumber property
     */
    dayNumber?: number;
    /**
     * The dayOfWeek property
     */
    dayOfWeek?: number;
    /**
     * The dayOfYear property
     */
    dayOfYear?: number;

However, the deserializeIntoDateOnly call is expecting a Partial<DateOnly> where the DateOnly ends up being seen as the one from the abstractions library. The abstractions version doesn't contain the above fields. This is a name conflict on the generated DateOnly type vs the class from the abstractions library.

baywet commented 1 month ago

Hi @mbursill Thanks for using kiota and for reaching out. Can you share the description/schema for that model please?

mbursill commented 1 month ago

The schema: swagger.json

It was generated from a C# API with a very simple model:

public class UpdateWidgetRequest
{
    public UpdateWidgetRequest() { }
    public string? Name { get; set; }
    public int? Size { get; set; }
    public DateOnly? InspectionDate { get; set; }
    public int? Mass { get; set; }  
}

It was tested on Kiota 1.13, 1.14 and the latest preview.

baywet commented 1 month ago

Thanks for the additional information. It appears the generated OAS description is not what kiota would expect here. Instead of having a component schema for DateOnly being used as the referenced schema for InspectionDate, the property should be of type string and format date. See the OAS format registry

Maybe @captainsafia can help us here (from the ASP.net team)

mbursill commented 1 month ago

Looks like this got a recent fix:

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2799

The latest 6.6.1 release of Swashbuckle.AspNetCore generates the correct OAS.

baywet commented 1 month ago

Thanks for the additional information. So the right code gets generated now? Good to close?

mbursill commented 1 month ago

Yes, all good now.