Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !8183

[Qt5] add parameterized server support

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/basyskom-dege/Qt5ParameterizedServer into master Dec 14, 2020
  • Overview 0
  • Commits 12
  • Pipelines 0
  • Changes 37

Created by: basyskom-dege

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

This PR will enable multi server and parameterized server support for Qt5 generator. It uses similar classes like java does. There are getter and setter functions to choose between the different servers and to change the server attributes that are provided in the server object. Every endpoint can have its own server with arbitrary variables. If no server is provided, the global server will be used.

There are two new classes: ServerConfiguration and ServerVariable. A ServerConfiguration stores an URL, a description and a map<QString, ServerVariable> that stores all variables and their names. The SeverVariable represents one variable, that has a description, a default value and an enum where all possible values are stored.

To change the default variable, use this function in each API:

    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:

    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.

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

I also updated the README. It contains a small "guide", similar to this message here. This will also fix the issue #8164 (closed) PING @wing328 @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @MartinDelille (2018/03) @muttleyxd (2019/08)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/basyskom-dege/Qt5ParameterizedServer