Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date formatting for date-time types #600

Merged
merged 3 commits into from
Jan 28, 2025
Merged

Conversation

christianhelle
Copy link
Owner

This fixes #599

With the changes in this pull request, the following OpenAPI document:

openapi: '3.0.1'
paths:
  '/t/foo/{id}':
    get:
      operationId: getFoo
      parameters:
        - name: id
          in: path
          required: true
          format: int64
          type: integer
        - name: valid_from
          in: query
          required: true
          format: date
          type: string
        - name: valid_to
          in: query
          required: true
          format: date
          type: string
        - name: test_time
          in: query
          required: true
          format: time
          type: string
        - name: test_datetime
          in: query
          required: true
          format: date-time
          type: string
      responses:
        '200':
          description: No response was specified

generates the following Refit interface:

[Get("/t/foo/{id}")]
Task GetFoo(
    long id, 
    [Query(Format = "yyyy-MM-dd")] System.DateTimeOffset valid_from, 
    [Query(Format = "yyyy-MM-dd")] System.DateTimeOffset valid_to, 
    [Query] System.TimeSpan test_time, 
    [Query] System.DateTimeOffset test_datetime);

This pull request includes changes to the Refitter project, focusing on improving date handling and updating test cases. The most important changes include modifying the date format handling in ParameterExtractor.cs, updating test cases to reflect these changes, and converting the OpenAPI specification format from JSON to YAML.

Improvements to date handling:

Updates to test cases:

@christianhelle christianhelle added enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code labels Jan 28, 2025
@christianhelle christianhelle self-assigned this Jan 28, 2025
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.03%. Comparing base (f44d839) to head (170483f).
Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #600   +/-   ##
=======================================
  Coverage   95.02%   95.03%           
=======================================
  Files          54       54           
  Lines        2676     2677    +1     
=======================================
+ Hits         2543     2544    +1     
  Misses         99       99           
  Partials       34       34           
Flag Coverage Δ
unittests 95.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@christianhelle christianhelle merged commit ca84973 into main Jan 28, 2025
10 checks passed
@christianhelle christianhelle deleted the fix-datetime-format branch January 28, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

date-time parameters are encoded as date when iso8601 is used
2 participants