Skip to content

Apply ParameterDateFormat to date in header as well#4760

Open
Eruzo wants to merge 1 commit intoRicoSuter:masterfrom
Eruzo:apply-parameterdateformat-to-isdate-in-header
Open

Apply ParameterDateFormat to date in header as well#4760
Eruzo wants to merge 1 commit intoRicoSuter:masterfrom
Eruzo:apply-parameterdateformat-to-isdate-in-header

Conversation

@Eruzo
Copy link
Copy Markdown

@Eruzo Eruzo commented Feb 5, 2024

Given the following parameter:

ReferenceDate:
  description: |
    A query date provided by the calling system. If non supplied the current system date will be used
  name: X-Reference-Date
  in: header
  schema:
    type: string
    format: date
  example: "2022-04-23"

The generated code would be:

if (x_Reference_Date != null)
    request_.Headers.TryAddWithoutValidation("X-Reference-Date", ConvertToString(x_Reference_Date, System.Globalization.CultureInfo.InvariantCulture));

In this case the date is passed as a full date including the timestamp in the US format. This causes the request to be rejected.

The pull requests adds a check for IsDate in the same way it exists for query parameters. In addition a check for IsSystemNullable is added. The type for the parameter generated in the function call is System.DateTimeOffset? x_Reference_Date. Without the check the generated code does not generate the ?.ToString( with the null-conditional oprator causing a compile error.

Technically this would be a breaking I guess?

@Eruzo Eruzo force-pushed the apply-parameterdateformat-to-isdate-in-header branch from fcd15c4 to e2f2ffa Compare July 29, 2024 08:17
@Eruzo Eruzo force-pushed the apply-parameterdateformat-to-isdate-in-header branch from e2f2ffa to ab0f637 Compare November 26, 2024 06:46
@Eruzo Eruzo force-pushed the apply-parameterdateformat-to-isdate-in-header branch from ab0f637 to 7811b89 Compare March 25, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant