Skip to content

Use OpenAPIKit for more validation logic#880

Merged
simonjbeaumont merged 4 commits into
apple:mainfrom
mattpolzin:upstream-validation
May 12, 2026
Merged

Use OpenAPIKit for more validation logic#880
simonjbeaumont merged 4 commits into
apple:mainfrom
mattpolzin:upstream-validation

Conversation

@mattpolzin
Copy link
Copy Markdown
Contributor

@mattpolzin mattpolzin commented Mar 18, 2026

Motivation

OpenAPIKit provides some validation help in its latest versions that can be used here to reduce the amount of logic this project must maintain. For example, the generator need not crawl the document to validate all content types, this is the behavior of a Validation<OpenAPIKit.ContentType>.

Modifications

  • I've removed the reference validations entirely because they are now available in exactly the desired form upstream.
  • I replaced the existing implementation of ContentType check with one using OpenAPIKit's validation DSL. This mostly serves to avoid the need to maintain logic in this library that OpenAPIKit must maintain anyway (namely, there's no need to find the ContentType values to validate them, OpenAPIKit will validate all values of that type anywhere in the Document).

Result

Removed code, slightly different error messages.

Test Plan

Tests have been updated to reflect the new (though comparable) errors.

@mattpolzin mattpolzin force-pushed the upstream-validation branch from 0d88cf4 to 59eecdb Compare March 18, 2026 14:24
@simonjbeaumont
Copy link
Copy Markdown
Collaborator

Realise this is backing off another WIP PR but, after a preliminary glance, this seems like a win to me—thanks!

@mattpolzin mattpolzin force-pushed the upstream-validation branch from 59eecdb to d06ba71 Compare May 12, 2026 14:02
@mattpolzin mattpolzin force-pushed the upstream-validation branch from d06ba71 to 04e20aa Compare May 12, 2026 14:12
Comment thread Tests/OpenAPIGeneratorCoreTests/Parser/Test_validateDoc.swift
@mattpolzin mattpolzin marked this pull request as ready for review May 12, 2026 14:15
@mattpolzin
Copy link
Copy Markdown
Contributor Author

@simonjbeaumont absolutely no hurry on this PR, but I wanted to ping you since I left it open for quite a while as a draft but it has now been rebased against latest main and should be ready for review.

@simonjbeaumont
Copy link
Copy Markdown
Collaborator

@mattpolzin amazing, thank you!

@simonjbeaumont simonjbeaumont added the 🔨 semver/patch No public API change. label May 12, 2026
Copy link
Copy Markdown
Collaborator

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

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

LGTM!

@simonjbeaumont simonjbeaumont enabled auto-merge (squash) May 12, 2026 15:06
@simonjbeaumont simonjbeaumont merged commit 92deec8 into apple:main May 12, 2026
49 of 50 checks passed
@mattpolzin mattpolzin deleted the upstream-validation branch May 12, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants