OpenAPITools / OpenAPITools/openapi-generator

[REQ][JAVA-WIREMOCK] support named examples

Open
#17,725 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The java-wiremock generator supports examples specified like this:

openapi: 3.0.3
info:
  version: 1.0.0
  title: OpenAPI Petstore
paths:
  /:
    get:
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  dummyProp:
                    type: string
                    example: 'hello world' # this is supported

But it does not support examples specified like this:

openapi: 3.0.3
info:
 version: 1.0.0
 title: OpenAPI Petstore
paths:
 /:
   post:
     responses:
       '200':
         description: successful operation
     requestBody:
       content:
         application/json:
           schema:
             type: object
             properties:
               dummyProp:
                 type: string
             example: # this is not supported
               dummyProp: hello world

I suggest to add support for the latter as well.

Additional context

This was originally discussed in https://github.com/OpenAPITools/openapi-generator/pull/17614.
There it was also explained what the current problem is:

It's the initial parsing that does not report named examples, so they don't end up being generated.

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 the java-wiremock generator and its initial OpenAPI parsing path, then read the discussion in pull request 17614 for the reported parsing limitation. Done means schema-level named examples are parsed and become available to generated WireMock output, alongside the already supported property examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
backend-api-design, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.