Update openapi spec components#423
Open
nezhyborets wants to merge 32 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove 32 invalid redeclarations: duplicate primitive typealiases (Bool/String/Int/Double = Swift.X) within the same struct scope, and six `typealias String = [Swift.String]` entries that shadowed Swift.String in CodingKeys raw type position, breaking compilation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename reasoning event types: ResponseReasoningDelta/DoneEvent → ResponseReasoningTextDelta/DoneEvent; ResponseReasoningSummaryDelta/DoneEvent → ResponseReasoningSummaryTextDelta/DoneEvent - Reorder decoder chain to match new value indices (value29–50): new ReasoningText events inserted at 29/30 pushed Refusal, OutputText, WebSearch, ImageGen, MCP events down by 2; MCP call-arguments events moved from value40/41 to value42/43, freeing 40/41 for the two previously-missing ImageGen events - Add decoder entries for value40/41 (ImageGenCallInProgress/PartialImage) and value49 (MCPListToolsInProgress), which were absent in the old mapping - Update guard indices to match: value40/41 → value42/43, value49 → value51 - Update case comments to match spec wording Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generated OutputItem changed from a OneOf struct (value1…value12) to a discriminated enum with named cases. Rewrite init(from:) to decode the generated enum and switch on its cases. Also adds the 13 new cases introduced in the spec: functionToolCallOutputResource, computerToolCallOutputResource, toolSearchCall, toolSearchOutput, compactionBody, localShellToolCallOutput, functionShellCall, functionShellCallOutput, applyPatchToolCall, applyPatchToolCallOutput, mcpApprovalResponseResource, customToolCall, customToolCallOutputResource. Updates existing comments to use absolute URLs and aligns wording with the spec descriptions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The generated type now has readable case names, making the facade unnecessary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename Includable → IncludeEnum, TextPayload → ResponseTextParam, ToolChoicePayload → ToolChoiceParam - Replace LocalShellTool → LocalShellToolParam in Tool enum - Add new Tool cases: computer, computerUsePreview, webSearch, webSearchPreview, functionShell, custom, namespace, toolSearch, applyPatch - Drop Tool suffix from all enum case names Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Restore Tool suffix on all enum cases; rename codeInterpreter → codeInterpreterTool - Add required responseId param to ResponseAudioDoneEvent in test - Add logprobs:[] to mock SSE JSON for ResponseTextDeltaEvent (now required by spec) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Re-adds the OutputItem facade removed in the previous commit so that public call sites don't need to switch on Components.Schemas.OutputItem directly. The facade mirrors all 25 cases of the generated type and preserves the user-friendly names (reasoning, imageGenerationCall, localShellCall). Also removes the now-redundant ResponseStreamEvent.OutputItem typealias that pointed at the generated type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All discriminator blocks in the spec used propertyName values (e.g. 'type') whose enum strings don't match schema names, making explicit mapping required. Without it, strict OpenAPI tooling cannot resolve the correct schema from a discriminator value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 8efc593.
Adds `make generate` which runs swift-openapi-generator and then extracts the Components enum from the output into Components.swift, stripping typealias lines that shadow Swift built-in names and would cause invalid redeclaration build errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
query is deprecated and no longer sent by the API, causing keyNotFound decoding errors. Removed it from the required list in the spec. See openai/openai-openapi#544. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The stream event type was incorrectly mapped to the underscore variant in ModelResponseStreamEventType; corrected to match the spec value response.output_text.annotation.added. fixMappingError() was doing the opposite transformation (dot→underscore) before decoding, which broke decoding after the generated enum was updated to use the spec's dot-separated value. Removed the function along with its call site; getPayloadType() is retained as it serves an unrelated fallback purpose. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The API does not send name in response.function_call_arguments.done events, despite the spec marking it required. Removed it from required. See openai/openai-openapi#545. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 23 changed files in this pull request and generated 10 comments.
Comments suppressed due to low confidence (1)
Sources/OpenAI/Public/Schemas/Edited/Tool.swift:57
Tool.init(from:)uses a trial-and-error decode strategy (manydo/try/catchattempts). With the newly added tool cases, this makes decoding increasingly expensive because most cases will fail before the correct one succeeds. Prefer decoding a lightweight discriminator first (e.g.,_type/type) and then decoding exactly one concrete schema based on that value; this improves performance and keeps the implementation scalable as more tool variants are added.
public init(from decoder: any Decoder) throws {
var errors: [any Error] = []
do {
self = .fileSearchTool(try .init(from: decoder))
return
} catch {
errors.append(error)
}
Replaces the fragile try-catch chain with a type-first switch over ModelResponseStreamEventType, making every event type's handler explicit and compiler-enforced. Also removes the stale response.reasoning_summary.delta/done event types and the ReasoningSummaryEvent enum, which have no corresponding generated schema types and are absent from the current OpenAI API reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ingStreamed overloads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove erroneous leading space from top-level keys and properly indent list items under paths: and schemas: so the config is unambiguously valid YAML. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Validate that exactly two arguments are passed before indexing sys.argv, so a missing argument produces a clear usage message instead of a bare IndexError. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Make text and toolChoice optional (spec marks both as optional) - Change status from String to typed Status? (Schemas.Response.Value3Payload.StatusPayload), adding cancelled and queued to the documented values - Change truncation from String? to typed Truncation? (Schemas.ResponseProperties.TruncationPayload), update doc comment to match current spec wording - Add model doc comment explaining why it stays as non-optional String rather than the spec's optional ModelIdsResponses enum - Deprecate user field, pointing to safetyIdentifier and promptCacheKey - Add 11 missing fields: background, completedAt, conversation, maxToolCalls, outputText, prompt, promptCacheKey, promptCacheRetention, safetyIdentifier, serviceTier, topLogprobs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ResponseObject+Mock.swift with a makeMock(output:tools:status:) helper following the pattern of other mock extensions. Update ResponsesEndpointTests to use it, removing the inline memberwise init and the private makeResponse helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ptional Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…params Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Re-generate Components with the latest OpenAPI spec. Update manually maintained code to work with the new Components
Why
It hasn't been updated for a very long time. It could fix some issues and enable people to use newer APIs.
Details
Components.swiftwith a version generated from the latest OpenAI OpenAPI spec (openapi.with-code-samples.yml) usingopenapi-generator+ a custom extraction script (Scripts/extract_components.py).Makefiletarget to automate future spec updates (make generate).OutputItem,ResponseStreamEvent,Tool,CreateModelResponseQuery,ResponseObject, etc.) to align with the new schema.output_text.annotation.addedevent type mapping and removes the now-unnecessaryfixMappingErrorworkaround.WebSearchActionSearch.queryandResponseFunctionCallArgumentsDoneEvent.nameoptional to match what actually received from API