Skip to content

Added unified OpenAPI generator extensions and broader client generation controls - #715

Draft
GoodforGod wants to merge 6 commits into
masterfrom
feature/openapi-generator-contract-improvements
Draft

Added unified OpenAPI generator extensions and broader client generation controls#715
GoodforGod wants to merge 6 commits into
masterfrom
feature/openapi-generator-contract-improvements

Conversation

@GoodforGod

@GoodforGod GoodforGod commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Add unified OpenAPI generator extensions and broader client generation controls.

  • replace legacy interceptor/annotation options with extensions
  • support global/tag/operation extension scopes
  • add additionalMethodAnnotations, additionalTypeAnnotations, model/enum annotations via extensions
  • add interceptorType / interceptorTag
  • add %{configPath} substitution and serverConfigPrefix
  • add clientMapping.type to override generated client response mapping annotations
  • add useSecurityDeclarationOrder
  • support anonymous OpenAPI security {} and preserve anonymous access fallback
  • use 401 Unauthorized for auth fallback and not 403 Forbidden
  • add clientResponseMode=SEALED | SUCCESSFUL
  • generate narrowed successful client return types in SUCCESSFUL mode
  • generate typed per-operation client response exceptions
  • generate *SuccessfulResponseMapper operation mappers
  • make generated response mappers open / @DefaultComponent
  • simplify shared response interfaces by avoiding duplicated model-field passthrough methods
  • pass HttpHeaders for raw/binary request and response body handling
  • generate mutable top-level optional args classes for Java client methods

Merge after #714


Extensions:

extensions: """
{
  "*": {
    "additionalMethodAnnotations": ["@Deprecated"],
    "additionalTypeAnnotations": ["@Deprecated"],
    "interceptorTag": ["ru.tinkoff.example.MyGlobalTag"]
  },
  "tags": {
    "pet": {
      "additionalMethodAnnotations": ["@ru.tinkoff.example.PetOperation"],
      "interceptorType": "ru.tinkoff.example.PetInterceptor",
       "clientMapping": {
        "type": "ru.example.CreatePetResponseMapper"
      }
    }
  },
  "operations": {
    "listPets": {
      "additionalMethodAnnotations": ["@ru.tinkoff.example.ListPets"],
      "interceptorType": "ru.tinkoff.example.MyInterceptor",
      "interceptorTag": ["ru.tinkoff.example.MyTag"]
    }
  }
}
"""

Режим обработки HTTP-ответов

Текущий режим

Метод возвращает типизированную обёртку над всеми возможными HTTP-ответами:

PetApiResponse createPet(...);

Внутри PetApiResponse находятся отдельные типы для каждого ожидаемого статуса:

CreatePet200ApiResponse
CreatePet400ApiResponse
CreatePet404ApiResponse
CreatePet500ApiResponse

Новый режим если новый флаг Включен его

Метод возвращает непосредственно успешный результат:

Pet createPet(...) throws PetsApiHttpClientResponseException;

При получении ошибочного HTTP-статуса, например 400, 404 или 500, выбрасывается:

PetsApiHttpClientResponseException

Из исключения можно получить:

  • statusCode;
  • HTTP-заголовки;
  • типизированное тело ошибки.

- Keep old per-client behavior via `clientConfigPrefix`
- Log generated clients with their final `(configPath)`
… same OpenAPI model. The generated interface exposes common model fields plus a status-code accessor, so callers can handle grouped responses without switching over every concrete status response.

Status accessor names are selected with collision fallback:
statusCode, httpStatusCode, statusCodeMethod, httpStatusCodeMethod, then the same names with _ prefix.
Also adds Java/Kotlin coverage with a same-response-model fixture, including renamed model lookup like Error -> ModelError.
…rget(TYPE)`.

- Updated Java annotation processor and KSP to treat annotated components as default declarations.
- Added Java and KSP conflict-resolution tests for:
  - default component usage without override
  - override by `@Component`
  - override by factory method
  - tag-specific override behavior
  - conditional component override
- Move enum JSON/request mappers into top-level @module factories
- Restore richer OpenAPI javadocs for models, operations, and enums
- Generate record with-methods and top-level mutable optional args
- Add focused OpenAPI fixtures and regression tests
- Default mode is `BYTES`, generating `byte[]` / `ByteArray` for top-level bare object bodies. `RAW` mode generates HTTP body abstractions instead: `HttpBodyOutput` / `HttpBodyInput` depending on client/server direction.
- Also keeps nested model `object` fields as `Object` / `Any`, adds HTTP body mappers, and covers Java/Kotlin client/server generation with bare object request/response tests.
…n controls.

- replace legacy `interceptor`/`annotation` options with `extensions`
- support `global/tag/operation` extension scopes
- add `additionalMethodAnnotations`, `additionalTypeAnnotations`, `model/enum` annotations via extensions
- add `interceptorType` / `interceptorTag`
- add %{configPath} substitution and serverConfigPrefix
- add `clientMapping.type` to override generated client response mapping annotations
- add `useSecurityDeclarationOrder`
- support anonymous OpenAPI `security {}`` and preserve anonymous access fallback
- use `401 Unauthorized` for auth fallback and not `403 Forbidden`
- add `clientResponseMode=SEALED | SUCCESSFUL`
- generate narrowed successful client return types in `SUCCESSFUL` mode
- generate typed per-operation client response exceptions
- generate ``*SuccessfulResponseMapper` operation mappers
- make generated response mappers `open / @DefaultComponent`
- simplify shared response interfaces by avoiding duplicated model-field passthrough methods
- pass `HttpHeaders` for raw/binary request and response body handling
- generate mutable top-level `optional args` classes for Java client methods
@GoodforGod GoodforGod added this to the v2.0.0 milestone Jul 11, 2026
@GoodforGod GoodforGod added new feature New feature request improvement Improvements to existing features module: openapi Related to Openapi module labels Jul 11, 2026
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

Test Results

201 tests   201 ✅  12m 47s ⏱️
  5 suites    0 💤
  5 files      0 ❌

Results for commit f371a29.

♻️ This comment has been updated with latest results.

@github-actions

Copy link
Copy Markdown

Dependency Vulnerability Report

Found 2 vulnerabilities across 2 coordinates.

Checked 159 Maven coordinates from gradle/libs.versions.toml via OSV.dev.

com.fasterxml.jackson.core:jackson-databind:2.22.0

Aliases: jackson2-databind

  • GHSA-5jmj-h7xm-6q6v, CVE-2026-54515: jackson-databind has case-insensitive deserialization bypasses per-property @JsonIgnoreProperties

io.undertow:undertow-core:2.4.2.Final

Aliases: undertow-core

  • GHSA-3x3v-w654-m28m, CVE-2026-3260: Undertow: Denial of Service via Multipart/Form-Data Parsing on HTTP GET Requests

@github-actions

Copy link
Copy Markdown

Dependency Update Report

Update level: patch

Found 12 dependency updates.

gradle/libs.versions.toml

  • jackson: 3.2.0 -> 3.2.1
  • jdbc-postgresql (org.postgresql:postgresql, inline:127): 42.7.12 -> 42.7.13
  • grpc-java: 1.82.1 -> 1.82.2
  • byte-buddy: 1.18.10 -> 1.18.11
  • s3client-aws (software.amazon.awssdk:s3, inline:253): 2.46.18 -> 2.46.21
  • ksp: 2.3.9 -> 2.3.10
  • netty: 4.2.15.Final -> 4.2.16.Final
  • zeebe: 8.9.11 -> 8.9.12
  • logback: 1.5.37 -> 1.5.38
  • jackson2-coreline: 2.22.0 -> 2.22.1
  • undertow-servlet: 2.3.25.Final -> 2.3.26.Final

buildSrc/build.gradle

  • line 7: tools.jackson.core:jackson-databind (jackson-databind) 3.2.0 -> 3.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvements to existing features module: openapi Related to Openapi module new feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant