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
  • !10614

[ K6 Generator ] Further K6 OpenAPI generator enhancements (request body example data extraction, support for generating scenario tests and load tests out of the box, and much more)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/DataInMotion/k6-openapi-extract-examples-enhancements into master Oct 17, 2021
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 7

Created by: ideas-into-software

Following up on the "parameter example data extraction" enhancement merged via https://github.com/OpenAPITools/openapi-generator/pull/9750, this MR brings additional significant improvements to the K6 OpenAPI generator, i.e.:

  • request body example data extraction
  • request grouping and ordering
  • response visibility
  • request data extraction for chaining requests

Most of these are accomplished via custom OpenAPI extensions (https://swagger.io/docs/specification/openapi-extensions/) introduced, i.e.:

  • x-k6-openapi-operation-grouping – operation grouping - group operations and define their ordering; useful e.g. for automatically generated scenario tests
  • x-k6-openapi-operation-response – operation response - for now, allows to hide given operation response, so that in case of multiple 2xx responses, generated script checks only against e.g. code 200 responses
  • x-k6-openapi-operation-dataextract – extract data from operation - allows to specify path to value in body of response which should be extracted and assigned to variable for later use by other operations; useful e.g. for automatically generated load test scripts

Code is documented. Entire solution will be showcased as part of the upcoming EclipseCon 2021 session: "Automated testing of OpenAPI-described RESTful microservices utilizing open source tools" https://www.eclipsecon.org/2021/sessions/automated-testing-openapi-described-restful-microservices-utilizing-open-source-tools

In a nutshell, with these additional enhancements, it possible not only to specify all of the example data and use it in the ready-to-run generated script, but to also generate ready-to-run scenario tests as well as load tests.

This allows for integrating the entire solution into CI/CD pipeline, i.e. as an additional, post-automated-deployment step, running automated REST API testing via automatically generated smoke tests / load tests / scenario tests, generated off on latest OpenAPI spec.

Obviously, generating OpenAPI spec itself is out of the scope for this project – but can be easily integrated into pipeline via existing gradle/maven plugins (e.g. io.swagger.core.v3.swagger-gradle-plugin) and run in a separate, earlier, step of the pipeline. Also, for automated REST API testing as part of CI/CD pipeline, continuous deployment must be in place – i.e. latest version of application exposing such REST API must be first deployed.

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 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    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*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/DataInMotion/k6-openapi-extract-examples-enhancements