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

Apply ParameterDateFormat to date in header as well #4760

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Eruzo
Copy link

@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
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