Description and Example for Parameters/Response #4
-
How do I add both descriptions (arbitrary text) and examples (some value used as try-it-out preset) to path/body parameters and corresponding response? Basically I'm looking for something like this (hacked generated webpage with HTML editor): I'm calling .openAPI(
summary: "...",
path: ["id": "1234567890"],
response: "AbCdeF",
responseType: .text(.plain)
) I guess description and example for HTTP-200 may go into |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@VaslD Hello!
@OpenAPIDescription("Identifier")
public var id: String
.openAPI(
path: PathParamters.self,
descriptions: .path("id", "Identifier")
)
If you don't want to wait for the library update you can use .openAPI(custom: \.parameters) {
$0?.append(
.value(
ParameterObject(
name: "id",
in: .path,
description: "Identifier",
required: true, // required for all path params
schema: .string,
example: .string("example")
)
)
)
} |
Beta Was this translation helpful? Give feedback.
-
@VaslD struct LoginParamters: Codable, OpenAPIDescriptable {
let username: String
let password: String
static var openAPIDescription: OpenAPIDescriptionType? {
OpenAPIDescription<CodingKeys>()
.add(for: .username, "Username")
.add(for: .password, "Password")
}
} |
Beta Was this translation helpful? Give feedback.
@VaslD Hello!
I tried to minimize the code required for the documentation, so I didn’t include some features, including a description for individual fields or objects.
But it’s easy for me to add such functionality since it is in demand.
Let's think about the best way to do this.
Some ideas:
openAPI
method/// Identifier
directivesIf you don't want to wait for the library update you can use
.openAPI(custom:)
func after mainopenAPI
.o…