-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add option for download progress, add test
- Loading branch information
Showing
31 changed files
with
3,911 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
generatorName: cpp-qt-client | ||
outputDir: samples/client/petstore/cpp-qt-addDownloadProgress | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/cpp-qt-client | ||
additionalProperties: | ||
packageName: CppQtPetstoreClient | ||
cppNamespace: test_namespace | ||
modelNamePrefix: PFX | ||
addDownloadProgress: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
samples/client/petstore/cpp-qt-addDownloadProgress/.openapi-generator-ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
24 changes: 24 additions & 0 deletions
24
samples/client/petstore/cpp-qt-addDownloadProgress/.openapi-generator/FILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
README.md | ||
client/CMakeLists.txt | ||
client/Config.cmake.in | ||
client/PFXCategory.cpp | ||
client/PFXCategory.h | ||
client/PFXEnum.h | ||
client/PFXHelpers.cpp | ||
client/PFXHelpers.h | ||
client/PFXHttpFileElement.cpp | ||
client/PFXHttpFileElement.h | ||
client/PFXHttpRequest.cpp | ||
client/PFXHttpRequest.h | ||
client/PFXOauth.cpp | ||
client/PFXOauth.h | ||
client/PFXObject.h | ||
client/PFXPet.cpp | ||
client/PFXPet.h | ||
client/PFXPetApi.cpp | ||
client/PFXPetApi.h | ||
client/PFXServerConfiguration.h | ||
client/PFXServerVariable.h | ||
client/PFXTag.cpp | ||
client/PFXTag.h | ||
client/PFXclient.pri |
1 change: 1 addition & 0 deletions
1
samples/client/petstore/cpp-qt-addDownloadProgress/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.8.0-SNAPSHOT |
150 changes: 150 additions & 0 deletions
150
samples/client/petstore/cpp-qt-addDownloadProgress/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# C++ Qt API client | ||
|
||
# | ||
|
||
OpenAPI Petstore | ||
|
||
- API version: 1.0.0 | ||
- Generator version: 7.8.0-SNAPSHOT | ||
|
||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
|
||
|
||
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* | ||
|
||
|
||
## Requirements | ||
|
||
Building the API client library requires: | ||
|
||
1. CMake 3.2+ | ||
2. Qt | ||
3. C++ Compiler | ||
|
||
## Getting Started | ||
|
||
example.h: | ||
```c++ | ||
|
||
#include <iostream> | ||
#include "../client/PFXPetApi.h" | ||
|
||
using namespace test_namespace; | ||
|
||
class Example : public QObject { | ||
Q_OBJECT | ||
PFXPet create(); | ||
public Q_SLOTS: | ||
void exampleFunction1(); | ||
}; | ||
|
||
``` | ||
example.cpp: | ||
```c++ | ||
#include "../client/PFXPetApi.h" | ||
#include "example.h" | ||
#include <QTimer> | ||
#include <QEventLoop> | ||
PFXPet Example::create(){ | ||
PFXPet obj; | ||
return obj; | ||
} | ||
void Example::exampleFunction1(){ | ||
PFXPetApi apiInstance; | ||
//OAuth Authentication supported right now | ||
QEventLoop loop; | ||
connect(&apiInstance, &PFXPetApi::addPetSignal, [&]() { | ||
loop.quit(); | ||
}); | ||
connect(&apiInstance, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) { | ||
qDebug() << "Error happened while issuing request : " << error_str; | ||
loop.quit(); | ||
}); | ||
PFXPet pfx_pet = create(); // PFXPet | Pet object that needs to be added to the store | ||
apiInstance.addPet(pfx_pet); | ||
QTimer::singleShot(5000, &loop, &QEventLoop::quit); | ||
loop.exec(); | ||
} | ||
``` | ||
|
||
## Documentation for Servers | ||
|
||
Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables: | ||
|
||
```yaml | ||
servers: | ||
- url: http://{server}:{port}/{basePath} | ||
description: Description of the Server | ||
variables: | ||
server: | ||
enum: | ||
- 'petstore' | ||
- 'qa-petstore' | ||
- 'dev-petstore' | ||
default: 'petstore' | ||
port: | ||
enum: | ||
- '3000' | ||
- '1000' | ||
default: '3000' | ||
basePath: | ||
default: v1 | ||
``` | ||
To change the default variable, use this function in each Api: | ||
```c++ | ||
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val); | ||
``` | ||
The parameter "serverIndex" will choose a server from the server list for each endpoint. There is always at least one server with index 0. The Parameter "operation" should be the desired endpoint operationid. | ||
Variable is the name of the variable you wish to change and the value is the new default Value. | ||
The function will return -1 when the variable does not exists, -2 if value is not defined in the variable enum and -3 if the operation is not found. | ||
|
||
If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function: | ||
```c++ | ||
void setServerIndex(const QString &operation, int serverIndex); | ||
``` | ||
Parameter "operation" should be your operationid. "serverIndex" is the index you want to set as your default server. The function will check if there is a server with your index. | ||
Here is an example of multiple servers in the servers array. The first server will have index 0 and the second will have index 1. | ||
```yaml | ||
servers: | ||
- url: http://{server}:8080/ | ||
description: Description of the Server | ||
variables: | ||
server: | ||
enum: | ||
- 'petstore' | ||
- 'qa-petstore' | ||
- 'dev-petstore' | ||
default: 'petstore' | ||
- url: https://localhost:8080/v1 | ||
``` | ||
|
||
## Documentation for Authorization | ||
|
||
Authentication schemes defined for the API: | ||
### petstore_auth | ||
|
||
|
||
- **Type**: OAuth | ||
- **Flow**: implicit | ||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog | ||
- **Scopes**: | ||
- write:pets: modify pets in your account | ||
- read:pets: read your pets | ||
|
||
|
||
## Author | ||
|
||
|
||
|
||
|
||
## License | ||
|
||
Apache-2.0 for more information visit [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.html) |
77 changes: 77 additions & 0 deletions
77
samples/client/petstore/cpp-qt-addDownloadProgress/client/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(CppQtPetstoreClient) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
|
||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Gui) | ||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network Gui) | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
add_library(${PROJECT_NAME} | ||
PFXCategory.h | ||
PFXPet.h | ||
PFXTag.h | ||
PFXPetApi.h | ||
PFXHelpers.h | ||
PFXHttpRequest.h | ||
PFXObject.h | ||
PFXEnum.h | ||
PFXHttpFileElement.h | ||
PFXServerConfiguration.h | ||
PFXServerVariable.h | ||
PFXOauth.h | ||
PFXCategory.cpp | ||
PFXPet.cpp | ||
PFXTag.cpp | ||
PFXPetApi.cpp | ||
PFXHelpers.cpp | ||
PFXHttpRequest.cpp | ||
PFXHttpFileElement.cpp | ||
PFXOauth.cpp | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
PUBLIC | ||
Qt${QT_VERSION_MAJOR}::Core | ||
Qt${QT_VERSION_MAJOR}::Network | ||
Qt${QT_VERSION_MAJOR}::Gui | ||
|
||
) | ||
|
||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" | ||
) | ||
|
||
install( | ||
TARGETS ${PROJECT_NAME} | ||
EXPORT ${PROJECT_NAME}Targets | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" | ||
) | ||
|
||
install( | ||
FILES ${HEADER_FILES} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
) | ||
|
||
install( | ||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
|
||
install( | ||
EXPORT ${PROJECT_NAME}Targets | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) |
5 changes: 5 additions & 0 deletions
5
samples/client/petstore/cpp-qt-addDownloadProgress/client/Config.cmake.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) | ||
|
||
check_required_components("@PROJECT_NAME@") |
Oops, something went wrong.