Skip to content

feat(core): support non-JSON response content types#81

Open
halotukozak wants to merge 3 commits into
masterfrom
feat/36-non-json-responses
Open

feat(core): support non-JSON response content types#81
halotukozak wants to merge 3 commits into
masterfrom
feat/36-non-json-responses

Conversation

@halotukozak

Copy link
Copy Markdown
Member

What

Response parsing previously only looked at application/json, silently dropping schemas for text/plain, application/octet-stream, etc.

  • Parser now picks the first matching response content type (JSON keeps priority via declaration order) and records it on the Response model (contentType: ContentType?).
  • text/plainString, application/octet-streamByteArray, including when the content has no explicit schema.
  • Ktor's body<T>() deserializes String/ByteArray natively, so no generator change beyond the resolved return type is needed.
  • Request bodies stay limited to JSON/form/multipart via the new ContentType.REQUEST_TYPES subset — request behavior unchanged.

Tests

  • Parser: text/plainSTRING, application/octet-stream (no schema) → BYTE_ARRAY, contentType recorded.
  • Generator: text response returns String, octet-stream returns ByteArray.
  • ContentTypeTest: full enum order + REQUEST_TYPES priority subset.

Closes #36

🤖 Generated with Claude Code

Response parsing previously only looked at application/json, silently
dropping schemas for other content types. Now the parser picks the
first matching response content type (JSON keeps priority) and records
it on the Response model.

text/plain maps to String, application/octet-stream to ByteArray —
including when the content carries no explicit schema. Ktor's body<T>()
deserializes both natively, so no generator changes beyond the resolved
return type are needed.

Request bodies stay limited to the existing JSON/form/multipart types
via ContentType.REQUEST_TYPES.

Closes #36

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Coverage Report

Overall Project 96.09% -0.17% 🍏
Files changed 92.49% 🍏

File Coverage
ApiSpec.kt 100% 🍏
ParametersGenerator.kt 96.3% -3.7%
SpecParser.kt 93.46% -0.27% 🍏
BodyGenerator.kt 92.93% -0.85%

@halotukozak halotukozak added this to the 1.0.0 milestone Jun 9, 2026
@halotukozak halotukozak self-assigned this Jun 9, 2026
@halotukozak halotukozak added the enhancement New feature or request label Jun 9, 2026
…sponses

# Conflicts:
#	core/src/main/kotlin/com/avsystem/justworks/core/parser/SpecParser.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support non-JSON response content types (text/plain, application/octet-stream, etc.)

1 participant