OpenAPITools / OpenAPITools/openapi-generator

[REQ] Auto generated test samples, unit test, integration test

Open
#13,854 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: CI/Test Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

We would like to auto generate tests from open API specs. I can see there testCase holder in this test API file : https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/api_test.handlebars#L40
but it is not clear how this works.

I found in the code https://github.com/OpenAPITools/openapi-generator/blob/574a70c3152a6d137db37f4df908fc824d733cc5/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L95 that this may come from x-schema-test-examples but it is not clear how to add this to open API yaml

Could please add some example of open API specs that allow tests generation or explain this in the documentation

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/openapi-generator/src/main/resources/python/api_test.handlebars and the referenced DefaultCodegen.java location to understand how x-schema-test-examples is consumed. Add an OpenAPI specification example or documentation showing how to define these examples for generated unit and integration tests, and verify that the explanation matches the existing generation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.