OpenAPITools / OpenAPITools/openapi-generator

[BUG] Vendor extensions in request body are ignored

Open
#6,765 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you search for related issues/PRs?
  • What's the version of OpenAPI Generator used?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Vendor extensions added to the request body section of the specification are not available in mustache templates.

openapi-generator version

3.4.1

OpenAPI declaration file content or url
Command line used for generation
paths:
  /users:
    post:
      summary: Adds a new user
      requestBody:
        x-foo: "extension" # <- not available in mustache templates
        content:
          application/json:
            schema:      # Request body contents
              type: object
              properties:
                id:
                  type: integer
                name:
                  type: string
              example:   # Sample object
                id: 10
                name: Jessica Smith
      responses:
        '200':
          description: OK
Steps to reproduce

Generate server API from the snippet above, using a custom bodyParts.mustache template containing {{{vendorExtensions.x-foo}}}, which will be empty.

Related issues/PRs
Suggest a fix

DefaultCodegen.fromRequestBody should probably copy the vendor extensions from RequestBody to CodegenParameter

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 DefaultCodegen.fromRequestBody and trace how RequestBody becomes a CodegenParameter, then inspect the custom bodyParts.mustache reproduction using vendorExtensions.x-foo. Done means the x-foo extension from the request body is available in the mustache template when generating the server API.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.