On this page

qt_add_openapi_client

Generates an HTTP client using a provided OpenAPI specification.

This command was introduced in Qt 6.11.

Note: This command is in technology preview and may change in future releases.

Synopsis

The command is defined in the OpenApiTools component of the Qt6 package, which can be loaded like this:

find_package(Qt6 REQUIRED COMPONENTS OpenApiTools)

qt_add_openapi_client(target
    SPEC_FILE filename.yaml
)

If versionless commands are disabled, use qt6_add_openapi_client() instead. It supports the same set of arguments as this command.

Description

The qt_add_openapi_client macro calls the Qt OpenAPI generator for a provided specification file. As a result, the command generates the scope of source files and adds them to the target source list. If the target doesn't exist, the generation will be stopped with an error message. For creating the target you can call qt_add_library or qt_add_executable functions.

Note: Always create the target before calling the qt_add_openapi_client function.

qt_add_openapi_client(<target>
    SPEC_FILE <file>
    [CPP_NAMESPACE <namespace>]
    [CLIENT_PREFIX <prefix>]
    [OUTPUT_DIRECTORY <dir>]
    [GENERATE_DOCUMENTATION]
    [DOCUMENTATION_OUTPUT_DIRECTORY <dir>]
    [OUTPUT_PUBLIC_HEADERS_DIR <dir>]
    [OUTPUT_PRIVATE_HEADERS_DIR <dir>]
)

Note: Only client code generation is currently supported.

Arguments

  • SPEC_FILE specifies an OpenAPI specification file, required for a code generation. The file should have a *.yaml extension.
  • CPP_NAMESPACE specifies a C++ namespace name to group generated classes.
  • CLIENT_PREFIX specifies a prefix for generated API and Model class names. Can be used for making class names unique among user projects.
  • OUTPUT_DIRECTORY specifies a directory for generated code.
  • GENERATE_DOCUMENTATION enables generation of doxygen documentation for generated classes.
  • DOCUMENTATION_OUTPUT_DIRECTORY specifies a directory that will store the doxygen documentation. The option can only be used together with GENERATE_DOCUMENTATION.
  • OUTPUT_PUBLIC_HEADERS_DIR specifies a directory that will store the list of generated public headers, otherwise you can find headers in the OUTPUT_DIRECTORY.
  • OUTPUT_PRIVATE_HEADERS_DIR specifies a directory that will store the list of generated private headers, otherwise you can find headers in the OUTPUT_DIRECTORY.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.