OpenAPI.NET.OData icon indicating copy to clipboard operation
OpenAPI.NET.OData copied to clipboard

URL Path parameters of type datetime are generated as strings with quotes

Open andrueastman opened this issue 2 years ago • 0 comments

Taking a look at the reference CSDL for the getDirectRoutingCalls odata Function fromDateTime and toDateTime parameters are represented as DateTimeOffset values.

<Function Name="getDirectRoutingCalls" IsBound="true">
<Parameter Name="bindingParameter" Type="Collection(microsoft.graph.callRecords.callRecord)"/>
<Parameter Name="fromDateTime" Type="Edm.DateTimeOffset"/>
<Parameter Name="toDateTime" Type="Edm.DateTimeOffset"/>
<ReturnType Type="Collection(microsoft.graph.callRecords.directRoutingLogRow)"/>
</Function>

The resulting openApi is as follows.

  '/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime=''{fromDateTime}'',toDateTime=''{toDateTime}'')':
    description: Provides operations to call the getDirectRoutingCalls method.
    get:
      tags:
        - communications.Functions
      summary: Invoke function getDirectRoutingCalls
      operationId: communications.callRecords.getDirectRoutingCalls
      parameters:
        - name: fromDateTime
          in: path
          description: 'Usage: fromDateTime=''{fromDateTime}'''
          required: true
          schema:
            pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$'
            type: string
            format: date-time
            nullable: true
        - name: toDateTime
          in: path
          description: 'Usage: toDateTime=''{toDateTime}'''
          required: true
          schema:
            pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$'
            type: string
            format: date-time
            nullable: true

The resulting path template has the URL with single quote parameters which is invalid according to https://docs.microsoft.com/en-us/graph/api/callrecords-callrecord-getdirectroutingcalls?view=graph-rest-1.0&tabs=http#request

We should probably not emit the single quotes in the URL template if we know the type is date-Time unless the type is explicitly specified as a string and have the url template as below.

  '/communications/callRecords/microsoft.graph.callRecords.getDirectRoutingCalls(fromDateTime={fromDateTime},toDateTime={toDateTime})':

andrueastman avatar Aug 11 '22 09:08 andrueastman