-
Notifications
You must be signed in to change notification settings - Fork 149
Closed
apple/swift-openapi-runtime
#103Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.
Milestone
Description
Description
Returning an empty dictionary as the response body fails to encode.
Error thrown:
EncodingError: invalidValue jsonPayload(additionalProperties: [:]) - at : Top-level jsonPayload did not encode any values.
Reproduction
openapi: '3.1.0'
paths:
/test:
get:
operationId: testEmpty
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: array
items:
type: stringfunc testEmpty(_ input: Operations.testEmpty.Input) async throws -> Operations.testEmpty.Output {
return .ok(.init(body: .json(.init(additionalProperties: [:]))))
}Package version(s)
OpenAPIKit 3.1.2
swift-openapi-generator 1.2.0
swift-openapi-runtime 1.3.2
swift-openapi-vapor 1.0.0
swift-openapi-context 1.0.0
Expected behavior
The response should be encoded as:
{}Environment
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0Metadata
Metadata
Assignees
Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.