openapi_generator 도구와 함께 사용하도록 설계된 Dart 어노테이션 패키지로, 개발자가 OpenAPI 사양에서 직접 Dart 모델과 API 클라이언트를 생성할 수 있게 해줍니다. 표준화된 API 정의 기반으로 코드 생성을 자동화함으로써 Flutter 및 기타 Dart 애플리케이션에 RESTful API를 쉽게 통합할 수 있습니다. 어노테이션은 OpenAPI 3.0 이상 표준에 부합하는 깔끔하고 타입 안전한 코드를 생성하도록 생성기를 안내합니다. 이 패키지는 API 우선 개발 방식을 따르는 팀에게 적합합니다.
사용 사례
OpenAPI 사양에서 클라이언트 코드 생성
API 모델 생성 자동화
API 우선 개발 워크플로우 활성화
Flutter 앱에서 REST API 통합
백엔드-프론트엔드 동기화 간소화
주요 기능
OpenAPI 스키마 정의에 대한 주석
openapi_generator 도구와의 통합
OpenAPI 3.0+ 지원
타입 안전한 생성 코드
크로스 플랫폼 호환성
적합한 대상
API 우선 개발 팀
Flutter 앱이 REST API 사용
OpenAPI 사양을 사용하는 프로젝트
자동 코드 생성을 찾는 개발자
일관된 API 계약이 필요한 팀
고려 사항
openapi_generator 도구 설정이 필요합니다
정확한 OpenAPI 사양에 따라 다름
생성된 코드는 수동 조정이 필요할 수 있습니다
런타임 API 수정에 적합하지 않습니다
정적 코드 생성에 제한됨
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
openapi-generator-dart
Like this library? Give us a star or a like!
⚠️ Java Requirement
Java is required to use this library.
The OpenAPI Generator CLI is a Java application.
Please ensure you have Java (version 8 or higher) installed and available in your system PATH.
You can check your Java installation with:
java -version
If you do not have Java installed, download it from Adoptium or Oracle.
⚠️ Deprecation & Breaking Change Notice
skipIfSpecIsUnchanged is Deprecated
The skipIfSpecIsUnchanged option is now deprecated and will be removed in the next major release.
Local OpenAPI specs are now automatically watched for changes.
If your spec file is in the lib/ folder, this works out of the box.
If your spec file is outside lib/, you must update or add a build.yaml to include your spec file as a source.
Example:
targets:$default:sources:-$package$-lib/**-openapi.yaml# or your spec file path
Remote specs:
Use the forceAlwaysRun (defaults to false) option to ensure the generator always runs.
This option is ignored for local specs.
When enabled, it modifies the annotated file to force regeneration. This might cause issues such as merge conflicts
Overview
This repository provides Dart/Flutter libraries for generating OpenAPI client SDKs directly from your OpenAPI specification. Inspired by Openapi Generator Cli (npm), it enables seamless integration into Dart and Flutter projects.
Libraries
Library
Description
Latest Version
openapi-generator
Dev dependency for generating OpenAPI client SDK via Dart source gen (usage)
openapi-generator-annotations
Annotations for configuring OpenAPI client SDK generation (usage)
If you are having issues with the generated code, this is not an problem with this package and creating an issue here will not help solve it. Its best to create the issue in the base OpenApi library since this package is a wrapper around that library for ease of use with Flutter/dart.
Below are some advanced configurations you may try.
Custom Templates:
Use the templateDirectory parameter to specify a custom code generation template.
Type & Import Mappings:
Use typeMappings and importMappings to control how OpenAPI types and models are mapped in Dart.
Reserved Words:
Use reservedWordsMappings to avoid conflicts with Dart reserved words.
Dependency Conflicts:
Use dependency_overrides in the generated package's pubspec.yaml and add pubspec.yaml to .openapi-generator-ignore to prevent overwrites.
Incorrect Generated Code:
Fix your OpenAPI spec (preferred).
Manually edit the generated code and add the files to .openapi-generator-ignore to prevent them from being overwritten.
.openapi-generator-ignore Example:
# Ignore all test files
test/*
# Ignore pubspec.yaml to preserve manual changes
pubspec.yaml