Table of Contents
openapi

FOSS-Update: basysKom contributions to the OpenAPI Generator

openapi

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.

Security

When working with APIs, authentication and authorization are important aspects to consider. While the OpenAPI specification addresses these topics, the OpenAPI Generator for Qt did not support any of them. As a first step, we implemented support for the BasicAuth and the ApiKey mechanism (OpenAPI 2.0/3.0) We also added BearerToken support 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.

ParameterizedServer

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.

ParameterSerialization

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.

Most of the improvements outlined above have been released with the OpenAPI generator v5.1.0.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Frank Meerkötter

Frank Meerkötter

Frank Meerkoetter is the Development Lead for basysKom GmbH, where he is consulting customers on industrial and embedded applications, often in combination with Qt. He is responsible for the technical consulting, system- and software-architecture within basysKom. He is the maintainer of Qt OPC UA and a contributor to the Qt project. He has a strong background in Embedded Linux, systems programming, distributed systems and application development. He holds a Master of Computer Science from the University of Applied Sciences in Darmstadt.
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on xing
Share on email
Share on stumbleupon
Share on whatsapp
Share on pocket

Read more

Qt
QML
Jeremias Bosch
Speedup your Qt/QML list scrolling on lowend devices

Something that has traditionally been complicated to achieve in Qt/QML, especially on low end hardware, is high performant list scrolling with complex delegates.
This has recently changed. In Qt 5.15, it is as simple as setting the new QML ListView property called reuseItems to true. For more details, have a look at the documentation.
In this blog post, I will explain how you can implement this feature in Qt Versions prior to 5.15.

Read More »
Pyhton
Python Qt
Sumedha Widyadharma
Using Shiboken2 to create Python bindings for a Qt library

With the release of Qt 5.12, Qt for Python is officially supported and can be used to write full-fledged Qt applications using Python as the main programming language.

This prompted us to also take a closer look at the bindings (the Python module is called PySide2) and also the underlying technology, namely the binding generator called Shiboken2.

Read More »