Skip to content

Cpp boost beast client redux #20971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

cwilson1776
Copy link

C++ Boost Beast client code generator (take 2)

Minor updates to original PR#12197 by LukasWoodtli. Includes various fixes so that sample/integration tests succeed, including updates required due to ongoing changes in openapi-generator, as well as changes in the "imposter" tool used by the tests. Also, rebased to current HEAD of master branch.

Generated example code is committed under the samples directory and integration tests are also available there. To build the sample and run the tests within the devcontainer:

sudo apt update && sudo apt install libboost-all-dev cmake
curl -L https://raw.githubusercontent.com/imposter-project/imposter-cli/main/install/install_imposter.sh | sudo bash -
cd samples/client/petstore/cpp-boost-beast/
./build-and-test.bash

Note that once the samples are compiled, the test procedure will use imposter-cli to spin up a mock server based on the petstore.yaml, but with pre-scripted responses to various queries in the test program. Spinning up this server takes a bit of time, since on first invocation it has to docker pull a fairly large image: outofcoffee/imposter. Once the mock server is finally running, vscode will show a popup that the server is listening on port 8080, and then the test will (automatically) continue.

I don't want to take credit away from Lukas Woodtli, who did the original work on this PR. I resurrected it because I wanted to see a C++ generator that (a) did not depend on a now-retired library cpprestsdk, nor (b) require an Xserver to operate (the qt client links against the QT GUI library for some reason).

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@ravinikam
@stkrwork
@etherealjoy
@MartinDelille
@muttleyxd

LukasWoodtli and others added 25 commits March 25, 2025 20:37
* Fixed names of the approval files for ApiTests.
* Silence warnings due to boost/property_tree/json_parser.hpp
* ApprovalTests only works when not using header-only boost::test
* More clean shutdown of imposter when test(s) fail
* Update petstore-config.yaml test config to add explicit values
  for all tested enpoints, rather than relying on imposter-provided
  default values. As of v4.5.2, imposter's defaults have changed.
* Fixed CppBoostBeastClientCodegen compilation error triggered by
  refactoring of getAdditionalProperties(Schema) -> ModelUtils.
@@ -0,0 +1,6 @@
generatorName: cpp-boost-beast-client
outputDir: samples/client/petstore/cpp-boost-beast/generated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR

how did you test the output in this new folder?

I tried running build-and-test.bash but got errors.

@wing328
Copy link
Member

wing328 commented Apr 23, 2025

please PM me via Slack when you've time to collaborate on this PR

thanks again for the contribution

https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants