Converter SPI methods for required fields should return non-optional types (#20)
Motivation
getRequiredRequestBodyAsText
currently returnsC?
instead ofC
. As the value should be required an optional in the return is causing issues.The errors are
Cannot convert value of type 'C?' to specified type
andCannot infer contextual base in reference to member 'text'
Modifications
Change the return type of
getRequiredRequestBodyAsText
Result
Code using a required requestBody now compiles without errors.
Swift OpenAPI Generator Runtime
This library provides common abstractions and helper functions used by the client and server code generated by Swift OpenAPI Generator.
Overview
It contains:
swift-openapi-generator
package plugin.ClientTransport
,ServerTransport
, and middleware.Usage
Add the package dependency in your
Package.swift
:Note that this repository does not have a 1.0 tag yet, so the API is not stable.
Next, in your target, add
OpenAPIRuntime
to your dependencies:The next step depends on your use case.
Using Swift OpenAPI Generator for code generation
The generated code depends on types from this library. Check out the adoption guides in the Swift OpenAPI Generator documentation to see how the packages fit together.
Implementing transports and middlewares
Swift OpenAPI Generator generates client and server code that is designed to be used with pluggable transports and middlewares.
Implement a new transport or middleware by providing a type that adopts one of the protocols from the runtime library:
ClientTransport
ClientMiddleware
ServerTransport
ServerMiddleware
You can also publish your transport or middleware as a Swift package to allow others to use it with their generated code.
Reporting issues
Please report any issues related to this library in the swift-openapi-generator repository.
Documentation
To learn more, check out the full documentation.