Skip to content

[typescript-angular2] Datetime parameters are not correctly formatted in request path #7476

Description

@arzhr
Description

I'm using codegen with an angular4 project.
I made an api endpoint with a datetime in the path like /line/{line:int}/exploitation/{xpdate:datetime}/incident

          {  
              "name":"xpdate",
              "in":"path",
              "required":true,
              "type":"string",
              "format":"date-time"
           },

The code generated for the previous snippet a datetime parameter is:
encodeURIComponent(String(xpdate))
Result is like 'Sat%20Dec%2024%202016%2001%3A00%3A00%20GMT%2B0100%20(Paris%2C%20Madrid)'
and the request fails !

I noticed datetime parameter is right generated for a query parameters:

           {  
              "name":"StartDate",
              "in":"query",
              "required":true,
              "type":"string",
              "format":"date-time"
           },

Generated code for query parameter is like:
if (startDate !== undefined) {
queryParameters = queryParameters.set('StartDate', startDate.toISOString());
}

Swagger-codegen version

2.3.1

Suggest a fix/enhancement

Generate specific method call for datatypes instead of generic toString() method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions