Skip to content

Partial Item Schema Support#20

Open
x-delfino wants to merge 2 commits intooapi-codegen:mainfrom
x-delfino:item_schema_support
Open

Partial Item Schema Support#20
x-delfino wants to merge 2 commits intooapi-codegen:mainfrom
x-delfino:item_schema_support

Conversation

@x-delfino
Copy link

@x-delfino x-delfino commented Feb 14, 2026

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 itemSchema field on the Media Type Object

Existing Support

Server

Nothing has been changed for the server implementation currently and I think all servers should be able to support streaming to clients

Client

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:

  • Added ItemSchema *SchemaDescriptor and IsSequential bool to RequestBodyDescriptor and ResponseContentDescriptor
  • Added IsSequentialMediaType(contentType string) bool helper — recognises aforementioned sequential/streaming content types

codegen/internal/gather.go:

  • Updated gatherFromMediaType() to also gather mt.ItemSchema when present

codegen/internal/configuration.go:

  • Extended DefaultContentTypes() to include aforementioned sequential/streaming content types

codegen/internal/gather_operations.go:

  • gatherResponse(): extracts mediaType.ItemSchema via schemaProxyToDescriptor(), sets IsSequential on ResponseContentDescriptor
  • gatherRequestBodies(): same for RequestBodyDescriptor

In terms of changes to generated code, types for items described by itemSchema will now be generated. The other changes are there to allow extending client/server generation where needed

Outstanding

SimpleClient

The SimpleClient will currently ignore these operations and so corresponding methods will not be generated:

{{- $simpleOp := isSimpleOperation . }}
{{- if $simpleOp }}

// The single content type must be JSON
return success.Contents[0].IsJSON

Would you want support for this in the simple client?

Strict Server

Are there plans to implement strict server similar to the previous version? IsSequential and ItemSchema are available on the descriptors to help handle this

Client -> Server

Reading the spec, I think it technically supports itemSchema in a Media Type Object that's in a Request Body Object rather than a Response Object but 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 on RequestBodyDescriptor

x-delfino and others added 2 commits February 14, 2026 13:02
@mromaszewicz
Copy link
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? :)

@x-delfino
Copy link
Author

awesome - thanks!

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.

2 participants