[REQ/PROPOSAL/OFFER TO IMPLEMENT] - Native OpenAPI Overlay Support

未关闭
#25,661 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
22/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
java, openapi
领域
api, build-system

调研方向

The payload names no source files. Start by reading how the generator loads and parses the input spec before code generation, since overlays must be applied at that point, and how the CLI, Gradle and Maven plugins pass the spec in. The author wants maintainers to agree on the integration approach (for example the overlay-jvm dependency) before any code is written, so check for a reply first. Done means one or more overlay files are applied before parsing, with tests across the CLI and build plugins.

由索引模型根据 Issue 内容生成。

描述

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

Customizing OpenAPI specifications for code generation currently requires modifying the original spec, using generator-specific configuration options, or introducing external preprocessing steps.

This is particularly relevant when dealing with imperfect or non-compliant OpenAPI specifications that cannot be modified at their source.

Additionally, some generators already provide complex configuration options to inject vendor extensions without modifying the original specification. A standardized overlay mechanism could reduce the need to implement and maintain such generator-specific workarounds.

Describe the solution you'd like

Support the OpenAPI Overlay Specification natively, allowing one or more overlay files to be passed alongside the original specification.

Overlays should be applied before parsing and code generation, with support across CLI, Gradle, and Maven integrations.

This would enable users to:

  • Inject vendor extensions: Add x-implements, x-class-extra-annotation, or x-spring-paginated without modifying the source specification.
  • Customize schemas: Add missing properties, change property types, rename properties, or adjust required constraints.
  • Work around problematic specifications: Fix incorrect schema definitions, missing metadata, or other issues in externally maintained OpenAPI documents.
  • Customize operations: Add annotations, modify parameters, or exclude certain endpoints from generation.
  • Apply cross-cutting customizations: Use JSONPath expressions to apply common metadata or modifications across multiple schemas or operations.

It could also reduce the maintenance burden on OpenAPI Generator by providing a standardized alternative to generator-specific configuration options such as schemaImplements or typeInfoDefaultImpls, where equivalent vendor extensions already exist.

Describe alternatives you've considered

External preprocessing using tools such as Redocly CLI or custom build tasks.

Additional context

overlay-jvm could be a suitable implementation dependency because it:

  • Is written in Java and can integrate directly into the existing generator pipeline.
  • Provides a simple API for applying overlays to OpenAPI documents.
  • Supports JSON/YAML and standards-based JSONPath expressions.
  • Implements OpenAPI Overlay Specification 1.1.0.
  • Avoids introducing external tools or runtimes into the generation workflow.

Its focused scope could make integration relatively straightforward, although compatibility with newer Overlay Specification versions would need consideration.

I'd be willing to work on implementing this feature and submit a PR, provided the maintainers are open to the approach. Feedback on the proposed integration and preferred architecture would be appreciated before proceeding.

But of course sticking to custom pre-processing step also works. It just seems like such a natural fit, hence the proposal.

主要语言
Java
星标
26.9k
派生
7.8k
平均合并
2 天 23 分钟
30 天内合并 PR
177

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenAPITools/openapi-generator 的其他 Issue

查看 OpenAPITools/openapi-generator 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。