OpenAPITools / OpenAPITools/openapi-generator

[BUG][All generators] Specification extension for info object is not exposed

Open
#4,211 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Client: TypeScript 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)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

According to the documentation the info object can be extended with Specification Extensions / Vendor extensions. However it does not work and generators does not expose that information to the templates.

It works for example in OpenApi object and Opeartion object but not in Info object

openapi-generator version

4.2.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Info service
  x-api-prefix: UFO
  version: 1.1.0
servers:
  - url: http://localhost:8080/v1
    description: PROD
paths:
  /info:
    get:
      summary: Get some info
      operationId: getInfo
      responses:
        200:
          description: OK

and mustach template (api.mustache):
{{this}}

Command line used for generation
java -jar ../../openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i openapi/info-service-v1.yaml -o serviceAPIs/Info -t ./openapi/template/

(build from master branch)

Same result with different generator:

npx openapi-generator generate -g typescript-axios -i openapi/info-service-v1.yaml -o serviceAPIs/Info -t ./openapi/template
Steps to reproduce

Just try to generate code, for Java generator look into file:
serviceAPIs/Notification/src/main/java/org/openapitools/client/api/DefaultApi.java
and try to find UFO

For npm look of UFO in api.ts file

Related issues/PRs
Suggest a fix

Fix should expose extensions to the mustache templates

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

Run the provided Java or typescript-axios generation command using the YAML declaration and custom api.mustache template. Compare the template output with the generated DefaultApi.java or api.ts, then trace how the Info object reaches templates. Done means the x-api-prefix value UFO is exposed and appears in generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.