Support for dictionaries in response/request body
Pre-release
Pre-release
Now we can use dictionaries in request/response body. For example:
let openAPIBuilder = OpenAPIBuilder(
title: "Swiftgger OpenAPI document",
version: "1.0.0",
description: "OpenAPI documentation for test structure purposes",
authorizations: [
.basic(description: "Basic authorization"),
.apiKey(description: "Api key authorization"),
.jwt(description: "JWT authorization"),
.oauth2(description: "OAuth authorization", flows: [
.implicit(APIAuthorizationFlow(authorizationUrl: "https://oauth2.com", tokenUrl: "https://oauth2.com/token", scopes: [:]))
]),
.openId(description: "OpenIdConnect authorization", openIdConnectUrl: "https//opeind.com")
]
)
.add([
APIObject(object: Fuel(level: 90, type: "GAS", productionDate: Date(), parameters: ["power", "speed"])),
])
.add(APIController(name: "VehiclesController", description: "Contoller for vehicles", actions: [
APIAction(method: .get,
route: "/vehicles/tags",
summary: "Get vehicle associated tags",
description: "GET action for downloading vehicle associated tags.",
responses: [
APIResponse(code: "200", description: "Vehicle tags", type: .dictionary(String.self)),
APIResponse(code: "401", description: "Unauthorized")
]
),
APIAction(method: .get,
route: "/vehicles/fuels",
summary: "Get vehicle associated fuels",
description: "GET action for downloading vehicle associated fuels.",
responses: [
APIResponse(code: "200", description: "Vehicle fuels", type: .dictionary(Fuel.self)),
APIResponse(code: "401", description: "Unauthorized")
]
)
]))
let openAPIDocument = openAPIBuilder.built()
Above code will produce response which in Swagger is displayed like on below image.