Skip to content

chore: add support for non-discriminator, oneOf query parameters#190

Merged
necipallef merged 7 commits into
mainfrom
chore/INTER-2037-oneof-union-support
May 15, 2026
Merged

chore: add support for non-discriminator, oneOf query parameters#190
necipallef merged 7 commits into
mainfrom
chore/INTER-2037-oneof-union-support

Conversation

@mcnulty-fp
Copy link
Copy Markdown
Contributor

@mcnulty-fp mcnulty-fp commented May 13, 2026

This PR updates the handling for oneOf constructs that do not use a discriminator to allow query parameters to use a union type to expand the accepted types for a parameter without breaking backward compatibility. This functionality will be used for the pending changes to expand start and end to accept a date-time string.

These template updates do not add JSON serialization and deserialization support for the generated type alias for a union type because that functionality is not yet needed.

Itemized changes:

  • Update model_oneof.mustache to generate a type alias rather than a container class when a oneOf construct does not use a discriminator. This allows additional types to be used for query parameters without breaking backward compatibility.
  • Update partial_api_args.mustache to generate type annotations for parameters that use oneOf construct without a discriminator.
  • Update api.mustache to handle query parameters that use a union type when their schema is a oneOf construct without a discriminator.
  • Update model_doc.mustache to document that a oneOf construct without a discriminator is a type alias.

See #191 for the code generated after these template updates and the schema is updated to use a oneOf for start and end.

- Update `model_oneof.mustache` to generate a type alias rather than
  a container class when a `oneOf` construct does not use a
  discriminator. This allows additional types to be used for query
  parameters without breaking backward compatibility.
- Update `partial_api_args.mustache` to generate type annotations for
  parameters that use `oneOf` construct without a discriminator.
- Update `api.mustache` to handle query parameters that use a
  union type when their schema is a `oneOf` construct without a
  discriminator.
- Update `model_doc.mustache` to document that a `oneOf` construct
  without a discriminator is a type alias.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2925 2108 72% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: cf5c361 by action🐍

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the OpenAPI generator templates to support oneOf query parameters that don't use a discriminator, generating a Python type alias (Union[...]) instead of a container class. This enables expanding accepted parameter types (e.g. allowing both date and date-time for start/end) without breaking backward compatibility.

Changes:

  • model_oneof.mustache now emits a Union type alias for non-discriminator oneOf schemas.
  • api.mustache and partial_api_args.mustache generate proper imports, type annotations, and runtime serialization branches (datetime/date/other) for union-typed query parameters.
  • model_doc.mustache documents the generated type alias.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
template/model_oneof.mustache Generate Union type alias instead of model class for non-discriminator oneOf.
template/partial_api_args.mustache Emit Annotated[Optional[...]] type hints for oneOf composed-schema params.
template/api.mustache Add union-imports workaround and runtime serialization branch for oneOf query params.
template/model_doc.mustache Document non-discriminator oneOf as a type alias.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread template/api.mustache Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mcnulty-fp mcnulty-fp marked this pull request as ready for review May 13, 2026 20:57
erayaydin
erayaydin previously approved these changes May 14, 2026
Copy link
Copy Markdown
Member

@erayaydin erayaydin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just added a couple of notes. Looks like the Server API can parse it with or without the colon in the current usage

Comment thread template/api.mustache Outdated
Comment thread template/api.mustache Outdated
@mcnulty-fp mcnulty-fp requested a review from erayaydin May 14, 2026 13:55
Copy link
Copy Markdown
Member

@erayaydin erayaydin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think assuming the timezone info could lead to issues, so I submitted a request change. Happy to discuss it further 😇

Comment thread template/api.mustache Outdated
- Update `model_oneof` template to use AwareDatetime to require
  oneOf parameters to have a timezone.
- Update `api` template to assume a timezone is set on the datetime
  query parameter.
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ This PR doesn't contain any changesets. If there are user-facing changes, don't forget to run:

pnpm exec changeset

to create a changeset.

@mcnulty-fp mcnulty-fp requested a review from erayaydin May 14, 2026 15:50
Copy link
Copy Markdown
Member

@erayaydin erayaydin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@necipallef necipallef merged commit 3de1de1 into main May 15, 2026
17 of 23 checks passed
@necipallef necipallef deleted the chore/INTER-2037-oneof-union-support branch May 15, 2026 09:18
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.

4 participants