Open
Conversation
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Thanks, I will look over this. I've not pushed it yet, but I'm 90% done with item schemas on my end as well. I'll see what you've done to see if anything is better and add you as a co-author if I borrow anything, deal? :) |
Author
|
awesome - thanks! |
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.
AI Usage Disclosure: Claude Code Opus 4.6 was used in developing this PR
Apologies for raising this PR without opening an issue and discussing first
OpenAPI 3.2 introduced support for sequential and streaming data, including:
This is done using the
itemSchemafield on the Media Type ObjectExisting Support
Server
Nothing has been changed for the server implementation currently and I think all servers should be able to support streaming to clients
http.Flushershould be implemented on thehttp.ResponseWriterso they can send then flushhttp.NewResponseController(ctx.Response()).Flush()https://echo.labstack.com/docs/cookbook/sse*Context.Stream()with helpers available for SSEctx.ResponseWriter().Flusher()https://iris-go.gitbook.io/iris/responses/sse#server-side-code-examplefasthttp.StreamWriteras shown in https://github.com/gofiber/recipes/blob/master/sse/main.goClient
Nothing has been changed on the client generation. The base client should be able to handle the events from *http.Response without further changes.
Changes
This PR includes the following changes, providing additional support for ItemSchema:
codegen/internal/operation.go:ItemSchema *SchemaDescriptorandIsSequential booltoRequestBodyDescriptorandResponseContentDescriptorIsSequentialMediaType(contentType string) boolhelper — recognises aforementioned sequential/streaming content typescodegen/internal/gather.go:gatherFromMediaType()to also gathermt.ItemSchemawhen presentcodegen/internal/configuration.go:DefaultContentTypes()to include aforementioned sequential/streaming content typescodegen/internal/gather_operations.go:gatherResponse(): extractsmediaType.ItemSchemaviaschemaProxyToDescriptor(), setsIsSequentialonResponseContentDescriptorgatherRequestBodies(): same forRequestBodyDescriptorIn terms of changes to generated code, types for items described by
itemSchemawill now be generated. The other changes are there to allow extending client/server generation where neededOutstanding
SimpleClient
The SimpleClient will currently ignore these operations and so corresponding methods will not be generated:
oapi-codegen-exp/experimental/codegen/internal/templates/files/client/simple.go.tmpl
Lines 39 to 40 in 71d4907
oapi-codegen-exp/experimental/codegen/internal/clientgen.go
Lines 136 to 137 in 71d4907
Would you want support for this in the simple client?
Strict Server
Are there plans to implement strict server similar to the previous version?
IsSequentialandItemSchemaare available on the descriptors to help handle thisClient -> Server
Reading the spec, I think it technically supports
itemSchemain aMedia Type Objectthat's in aRequest Body Objectrather than aResponse Objectbut I don't think that's a typical use case and isn't a use case specifically referenced in the documentation. If you don't want to support it, we can revert the changes onRequestBodyDescriptor