Over the last months basysKom contributed a number of improvements to the OpenAPI Generator project. OpenAPI as a standard provides a structured way to define, implement, test and maintain REST-like APIs. A key feature of OpenAPI is a formal language which is used to specify APIs. This language can be used to automatically generate client- and server-side stub code. The OpenAPI Generator supports code generation for over 40 languages and frameworks. The support for Qt was, so-far, a bit lacking. This article provides an overview of our ongoing work to improve the Qt-support in the OpenAPI Generator. We have split this post in sections, where we briefly highlight the change, what it enables and where you find the commit.
BasicAuth and the ApiKeymechanism (OpenAPI 2.0/3.0) We also added
BearerTokensupport which is part of OpenAPI 3.0. The according pull request can be found here.
In addition to that, we worked on the Oauth2 security feature. The generator now allows to use all the Oauth2 flows from the OpenAPI Specification to generate access tokens: Implicit Flow, Password Flow, Authorization Code Flow and the Implicit Flow. This pull request was recently merged and can be found here.
Next up there is the Parameterized Server support. This is a feature where the server URL can be parameterized with a placeholder to select the actual endpoint being used. This can be useful when there are several server endpoints e.g. when there is a develop, staging and production environment. The merged pull request can be found here.
OpenAPI uses Uniform Resource Identifier (URI) RFC3986 to identify a resource. The URI Template specification RFC6570 defines multiple ways on how a URI can be structured. Different delimiters for query, path or cookie parameters, for example. Query parameters are delimited by an ampersand by default, but you can choose from other delimiters according to the URI Template specification. OpenAPI defines a set of rules that are using the URI Template specification. It is called ParameterSerialization and allows to provide styling options for the parameter serialization in a request. We implemented this feature for Qt with this pull request.
Data types: Unique Items
OpenAPI allows to define data types as well as various properties of these data types. The
unique items feature allows to specify an array that should not contain duplicate items. This can be useful when you want to prevent that for example the same ID is used twice in one request. On the Qt-side this is exposed as a
QSet. Our contribution enables this feature now
Qt6 and further on
Qt6 was not yet supported by the Generator. Enabling it was easy and boiled down to preventing the generator from emitting certain deprecated functions. The code produced by the generator is now expected to also compile without warnings in Qt6 projects. The pull request can be found here.
basysKom is offering consulting, training and development services around Qt. We also work with Open Source projects to bring features & bugfixes upstream. Come talk to us for support in your next project.