chunk detection based on response format #59
Merged
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.
This introduces
AbstractChunkReader
and adds a few chunk readers with different chunk detection strategies. Also includes some auto selection heuristics based on detected response format and ability to specify a chunk reader atCtx
andClient
levels.Chunk readers available:
LineChunkReader
: Chunks delimited by newline. This was the only available strategy earlier. It is now the default when the response type is detected to be not ofOpenAPI.APIModel
type.JSONChunkReader
: Each chunk is a JSON. Whitespaces between JSONs are ignored. This is now the default when the response type is detected to be aOpenAPI.APIModel
.RFC7464ChunkReader
: A reader based on RFC 7464. Available for use by overriding throughClient
orCtx
.The
Client
andCtx
constructors take an additionalchunk_reader_type
keyword parameter. This can be one ofOpenAPI.Clients.LineChunkReader
,OpenAPI.Clients.JSONChunkReader
orOpenAPI.Clients.RFC7464ChunkReader
. If not specified, then the type is automatically determined based on the return type of the API call.