fabrikt-io /fabrikt

Generates Kotlin Code from OpenAPI 3 Specifications

★ 297⑂ 88👁 5⑃ 590● 273▤ 172
KotlinApache-2.0Created 2019-12-24try.fabrikt.io
下载:29.2.029.2.0 ↓29.2.02026-11-22
-1
日增长
297
stars
88
forks
5
watchers
590
prs
273
issues
172
releases

README

Fabrikt /ˈfa-brikt/ - Kotlin code from OpenAPI 3

 Introduction
 Features
 Examples
 Usage Instructions
   Command Line
   Generating from a JSON Schema document
   Gradle w/ custom task
   Gradle w/ plugin
   Maven
   Docker
 Getting the Most from Fabrikt
 Client authentication
 Configuration Options
 Migration Guide
 Original Motivation
 Building Locally
 Publishing
 Specific Features

 Introduction

This library was built to take advantage of the complex modeling features available in OpenAPI 3. It generates Kotlin data classes with advanced support for features such as:
 - Null Safety
 - Inlined schema definitions
 - Enumerations 
 - Sealed Classes
 - Polymorphism (@JsonSubTypes)
 - Maps of Maps of Maps
 - GraalVM Native Reflection Registration
 - Json Merge Patch (via JsonNullable) (add x-json-merge-patch: true to schemas)
 - Override Jackson Include NonNull (via JsonInclude) (add x-jackson-include-non-null: true to schemas)
 - Jackson's polymorphic subtype deduction (add x-jackson-subtype-deduction: true to the oneOf schema) to gain Sealed Interface polymorphism, without needing to declare a discriminator property. Requires subtypes to have distinguishing required fields.
 
as well as HTTP clients and controllers for a number of popular frameworks (see Features).

Fabrikt also generates models directly from a plain JSON Schema document — draft-04 through 2020-12, optionally nested inside a larger resource such as a Nakadi EventType manifest — with no OpenAPI spec required. See Generating from a JSON Schema document.

More than just bootstrapping, this library can be permanently integrated into your build tool and will ensure contract and code always match, even as APIs evolve in complexity.

 Try Fabrikt Online

Try Fabrikt with your own API spec in the Fabrikt Playground and see how it can help you generate code for your API clients and servers.



 Coordinates

xml

  io.fabrikt
  fabrikt



 Features

The library currently has support for generating:

 Models
   Jackson annotated data classes
   Kotlinx.serialization annotated data classes
 Clients
   OkHttp Client (w/ Jackson Models)
   OpenFeign annotated client interfaces
   Ktor Client (w/ Jackson & Kotlin Serialization models)
   Spring HTTP Interface annotated client interfaces
 Controllers
   Spring MVC annotated controller interfaces
   Micronaut HTTP annotated controller interfaces
   Ktor server routes and controller interfaces

Client generators can emit an opt-in security declaration through --http-client-opts OPENAPI_SECURITY: a scheme dictionary, the effective requirement of every operation, and a pure header resolver. See Client authentication.

OpenAPI 3.2 query operations are supported by all client targets and by Ktor and Micronaut controllers, including JSON request bodies. OpenFeign requires 13.14 or later and a transport that supports QUERY, such as feign-okhttp; its default HttpURLConnection transport does not. Spring HTTP Interface clients likewise require a suitab

Top issues

Discussions

Latest release

29.2.0 29.2.0 2026-11-22
What's Changed
 Add --additional-properties flag to control handling of undeclared object properties by @cjbooms in https://github.com/fabrikt-io/fabrikt/pull/863
 Share one additional properties map across discriminated allOf hierarchies by @mrhoeve in https://github.com/fabrikt-io/fabrikt/pull/861
 Fix inherited fields from nested discriminator parents by @mrhoeve in https://github.com/fabrikt-io/fabrikt/pull/871
 Fix allOf object classification with additional properties by @mrhoeve in https://github.com/fabrikt-io/fabrikt/pull/870
 Validate string constraints on array elements by @mrh

Snapshot: 2026-11-28T10:06:57Z · Data license Apache-2.0 · JSON