OpenAPI JSON 스키마 생성기를 사용하여 OpenAPI 3.0.0-3.1.0 문서에서 클라이언트 SDK를 자동 생성하십시오. 이 프로젝트는 모든 OpenAPI 및 JSON 스키마 기능을 지원하는 데 중점을 둔 코드 생성기입니다.
OpenApi JSON 스키마 생성기는 OpenAPI 문서 (3.0.0-3.1.0*이 지원됨)가 제공되는 API 클라이언트 라이브러리 (SDK Generend)의 자동 생성을 허용합니다. 이 프로젝트는 OpenAPI + JSON 스키마 사양을 100% 준수하는 데 중점을 둡니다. 목표는 OpenAPI +에 정의 된 모든 것을 완전히 지원하는 것입니다.
현재 다음 언어/프레임 워크가 지원됩니다.
| 특징 | 파이썬 | 자바 | 코 틀린 |
|---|---|---|---|
| 발전기 상태 | 안정적인 | 안정적인 | 안정적인 |
| OpenApi v3.0.0-3.1.0 섭취 | 엑스 | 엑스 | 엑스 |
| JSON 스키마 2020-12 지원 (구성 요소/스키마) | 엑스 | 엑스 | 엑스 |
| 구성 요소 스키마 클래스 + 문서화 | 엑스 | 엑스 | 엑스 |
| 다른 구성 요소 유형에 대해 생성 된 문서 : 헤더, 매개 변수, 요청 바디, ressponses, securityschemes | 엑스 | 엑스 | |
| 엔드 포인트에 대해 생성 된 메소드 JSON + DOCS를 보내거나받습니다 | 엑스 | 엑스 |
1var from hi-there 등으로 지원됩니다.우리는 불화 서버를 질문하고 서로를 도울 장소로 사용합니다. 슬랙과 매우 유사한 기능을 제공합니다. 여기에서 우리와 함께 할 수 있습니다 : https://discord.gg/mhb8wequyq
예; 기부금을 환영합니다! 모든 언어로 새 서버 스캐 폴드, 클라이언트 SDK 또는 문서 생성기를 추가하려면 PR 제출.
OpenAPI 사양은 2010 년 초기 생성 이후 3 개의 개정을 거쳤습니다. OpenApi-Json-Schema-Generator 프로젝트는 OpenAPI 사양과 다음과 같은 호환성을 가지고 있습니다.
| OpenApi JSON 스키마 생성기 버전 | OpenApi 사양 호환성 |
|---|---|
| 3.3.0+ | 3.0.0-3.1.0* |
| 3.1.0-3.2.1 | 3.0.0-3.1.0 |
| 1.0.0-3.0.0 | 3.0.0-3.0.3 |
OpenApi v3.1.0 사양 지원이 새로운/업데이트 된 2020-12 JSON 스키마 키워드가 포함됩니다.
참고 : 이러한 기능은 생성기 문서 스키마 기능에서도 볼 수 있습니다.
소스에서 빌드하려면 다음과 같이 설치하고 $PATH:
Java 11
Apache Maven 3.9.3 이상
프로젝트를 복제 한 후이 명령으로 소스에서이를 구축 할 수 있습니다.
mvn clean install 기본 빌드에는 최소한의 정적 분석이 포함되어 있습니다 (CheckStyle을 통해). PMD 및 SpotBugs로 빌드를 실행하려면 static-analysis 프로파일을 사용하십시오.
mvn -Pstatic-analysis clean installDocker Image는 독립형 실행 파일 역할을합니다. Homebrew를 통해 설치하거나 Java를 설치하거나 설치된 버전을 업그레이드 할 수없는 개발자를위한 대안으로 사용할 수 있습니다.
이 이미지로 코드를 생성하려면 로컬 위치를 볼륨으로 장착해야합니다.
예:
docker run --rm -v " ${PWD} :/local " openapijsonschematools/openapi-json-schema-generator-cli generate
-i https://raw.githubusercontent.com/openapi-json-schema-tools/openapi-json-schema-generator/master/src/test/resources/3_0/petstore.yaml
-g python
-o /local/out/python 생성 된 코드는 현재 디렉토리의 ./out/python 아래에 있습니다.
bin/run-in-docker.sh 사용하여 모든 개발을 수행 할 수 있습니다. 이 스크립트는 로컬 저장소를 Docker 컨테이너의 /gen 에 매핑합니다. 또한 ~/.m2/repository 적절한 컨테이너 위치에 매핑합니다.
mvn package 실행 :
git clone https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
cd openapi-json-schema-generator
./bin/run-in-docker.sh mvn package작업 디렉토리에서 빌드 아티팩트에 액세스 할 수 있습니다.
일단 제작되면 run-in-docker.sh OpenApi-Json-Schema-Generator-CLI의 실행 파일 역할을합니다. 코드를 생성하려면 /gen (예 : /gen/out )의 디렉토리로 출력해야합니다. 예를 들어:
./bin/run-in-docker.sh help # Executes 'help' command for openapi-json-schema-generator-cli
./bin/run-in-docker.sh list # Executes 'list' command for openapi-json-schema-generator-cli
./bin/run-in-docker.sh /gen/bin/python-petstore.sh # Builds the Python client
./bin/run-in-docker.sh generate -i src/test/resources/3_0/petstore.yaml
-g go -o /gen/out/python-petstore -p packageName=petstore_api # generates python client, outputs locally to ./out/python-petstore 이와 같은 오류가 발생하면 MVN Clean Install -U 명령을 실행하십시오.
org.apache.maven.lifecycle.lifecycleexecutionException : 목표 목표 org.apache.maven.plugins : maven-surefire-plugin : 2.19.1 : test (기본 테스트) : OpenApi-Json-Schema-Generator : 실행 중에 발생하는 유형 비 호환성 org.apache.maven.plugins : maven-surefire-plugin : 2.19.1 : test : java.lang.exceptioninInitializerERROR는 java.io.ioException으로 시전 할 수 없습니다
./run-in-docker.sh mvn clean install -U목표 org.fortasoft : Gradle-Maven-Plugin : 1.0.8 : 프로젝트에서 invoke (기본값) 프로젝트 Openapi-Json-Schema-Generator- gradle-Plugin-MVN-Wrapper : org.gradle.tooling.buildexception : Gradle 배포를 사용하여 빌드를 실행할 수 없습니다. 'https://services.gradle.org/distributions/gradle-4.7-bin.zip'
지금 : 이것에 대한 해결책이 없다 : |
Petstore.yaml 용 Python 클라이언트를 생성하려면 다음을 실행하십시오.
git clone https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
cd openapi-json-schema-generator
mvn clean package
java -jar target/openapi-json-schema-generator-cli.jar generate
-i https://raw.githubusercontent.com/openapi-json-schema-tools/openapi-json-schema-generator/master/src/test/resources/3_0/petstore.yaml
-g python
-o /var/tmp/python_api_client (Windows에있는 경우 마지막 명령을 java -jar targetopenapi-json-schema-generator-cli.jar generate -i https://raw.githubusercontent.com/openapi-json-schema-tools/openapi-json-schema-generator/master/src/test/resources/3_0/petstore.yaml -g python -oc:temppython_api_client )
사용 가능한 일반 옵션 목록을 얻으려면 java -jar target/openapi-json-schema-generator-cli.jar help generate 실행하십시오.
파이썬 지정 옵션 목록을 얻으려면 ( -c 옵션을 통해 구성 파일을 사용하여 생성기로 전달할 수 있음) java -jar target/openapi-json-schema-generator-cli.jar config-help -g python 실행하십시오.
다음과 같이 Petstore API에 대한 클라이언트를 구축 할 수 있습니다.
./bin/generate-samples.sh ./bin/generate_samples_configs/python.yaml(Windows에서 위의 명령을 실행하려면 Windows 용 Git Bash를 설치하십시오)
이 스크립트는이 명령으로 생성기를 실행합니다.
java -jar target/openapi-json-schema-generator-cli.jar generate
-i https://raw.githubusercontent.com/openapijsonschematools/openapi-json-schema-generator/master/src/test/resources/3_0/petstore.yaml
-g python
-t src/main/resources/python
--additional-properties packageName=petstore_api
-o samples/client/petstore/python여러 옵션이 있습니다. 파이썬 옵션은 여기에 문서화되어 있습니다.
help generate 명령으로 옵션을 얻을 수도 있습니다 (아래에서만 부분 결과 만 표시).
NAME
openapi-json-schema-generator-cli generate - Generate code with the specified
generator.
SYNOPSIS
openapi-json-schema-generator-cli generate
[(-a <authorization> | --auth <authorization>)]
[--api-name-suffix <api name suffix>] [--api-package <api package>]
[--artifact-id <artifact id>] [--artifact-version <artifact version>]
[(-c <configuration file> | --config <configuration file>)] [--dry-run]
[(-e <templating engine> | --engine <templating engine>)]
[--enable-post-process-file]
[(-g <generator name> | --generator-name <generator name>)]
[--git-host <git host>] [--git-repo-id <git repo id>]
[--git-user-id <git user id>] [--global-property <global properties>...]
[--group-id <group id>] [--hide-generation-timestamp]
[--http-user-agent <http user agent>]
[(-i <spec file> | --input-spec <spec file>)]
[--ignore-file-override <ignore file override location>]
[--ints-allowed-for-float-double-formats]
[--invoker-package <invoker package>] [--minimal-update]
[--model-name-prefix <model name prefix>]
[--model-name-suffix <model name suffix>]
[(-o <output directory> | --output <output directory>)] [(-p <additional properties> | --additional-properties <additional properties>)...]
[--package-name <package name>] [--release-note <release note>]
[--remove-enum-value-prefix] [--remove-operation-id-prefix]
[(-s | --skip-overwrite)] [--skip-operation-example]
[--skip-validate-spec] [--strict-spec <true/false strict behavior>]
[(-t <template directory> | --template-dir <template directory>)]
[(-v | --verbose)]
OPTIONS
-a <authorization>, --auth <authorization>
adds authorization headers when fetching the OpenAPI definitions
remotely. Pass in a URL-encoded string of name:header with a comma
separating multiple values
--api-name-suffix <api name suffix>
Suffix that will be appended to all API names ('tags'). Default:
Api. e.g. Pet => PetApi. Note: Only ruby, python, jaxrs generators
support this feature at the moment.
--api-package <api package>
package for generated api classes
--artifact-id <artifact id>
artifactId in generated pom.xml. This also becomes part of the
generated library's filename
--artifact-version <artifact version>
artifact version in generated pom.xml. This also becomes part of the
generated library's filename
-c <configuration file>, --config <configuration file>
Path to configuration file. It can be JSON or YAML. If file is JSON,
the content should have the format {"optionKey":"optionValue",
"optionKey1":"optionValue1"...}. If file is YAML, the content should
have the format optionKey: optionValue. Supported options can be
different for each language. Run config-help -g {generator name}
command for language-specific config options.
--dry-run
Try things out and report on potential changes (without actually
making changes).
-e <templating engine>, --engine <templating engine>
templating engine: "handlebars"(default) or "mustache"
--enable-post-process-file
Enable post-processing file using environment variables.
-g <generator name>, --generator-name <generator name>
generator to use (see list command for list)
--git-host <git host>
Git host, e.g. gitlab.com.
--git-repo-id <git repo id>
Git repo ID, e.g. openapi-generator.
--git-user-id <git user id>
Git user ID, e.g. openapijsonschematools.
--global-property <global properties>
sets specified global properties (previously called 'system
properties') in the format of name=value,name=value (or multiple
options, each with name=value)
--group-id <group id>
groupId in generated pom.xml
--hide-generation-timestamp
Hides the generation timestamp when files are generated.
--http-user-agent <http user agent>
HTTP user agent, e.g. codegen_csharp_api_client, default to
'OpenAPI-Generator/{packageVersion}/{language}'
-i <spec file>, --input-spec <spec file>
location of the OpenAPI spec, as URL or file (required if not loaded
via config using -c)
--ignore-file-override <ignore file override location>
Specifies an override location for the .openapi-generator-ignore
file. Most useful on initial generation.
--ints-allowed-for-float-double-formats
Integers are allowed in for type: number format:float/double
payloads
--invoker-package <invoker package>
root package for generated code
--minimal-update
Only write output files that have changed.
--model-name-prefix <model name prefix>
Prefix that will be prepended to all model names.
--model-name-suffix <model name suffix>
Suffix that will be appended to all model names.
-o <output directory>, --output <output directory>
where to write the generated files (current dir by default)
-p <additional properties>, --additional-properties <additional
properties>
sets additional properties that can be referenced by the mustache
templates in the format of name=value,name=value. You can also have
multiple occurrences of this option.
--package-name <package name>
package for generated classes (where supported)
--release-note <release note>
Release note, default to 'Minor update'.
--remove-enum-value-prefix
Remove the common prefix of enum values
--remove-operation-id-prefix
Remove prefix of operationId, e.g. config_getId => getId
-s, --skip-overwrite
specifies if the existing files should be overwritten during the
generation.
--skip-operation-example
Skip examples defined in operations to avoid out of memory errors.
--skip-validate-spec
Skips the default behavior of validating an input specification.
--strict-spec <true/false strict behavior>
'MUST' and 'SHALL' wording in OpenAPI spec is strictly adhered to.
e.g. when false, no fixes will be applied to documents which pass
validation but don't follow the spec.
-t <template directory>, --template-dir <template directory>
folder containing the template files
-v, --verbose
verbose mode
그런 다음 자동 생성 된 클라이언트를 사용할 수 있습니다. readme.md는 좋은 출발점입니다.
다른 발전기에는 샘플도 있습니다.
출력 (예 : 패키지 이름, 버전)을 사용자 정의하는 방법에 대한 Customization.md를 참조하십시오.
Maven, Gradle, Github 및 CI/CD와 OpenAPI 생성기를 통합하는 방법은 Integration.Md를 참조하십시오.
OpenAPI JSON 스키마 생성기 프로젝트는 Open API 사양 사용자에게 이익이됩니다. 프로젝트 자체에는 지정된 라이센스가 있습니다. 또한 다음 사항을 이해하십시오.
이 프로젝트에서 코드가 생성되면 소프트웨어 사용자가있는 것으로 간주되고 소유해야합니다. 생성 된 코드에 대한 보증은 표현되거나 묵시적입니다. 당신은 당신이 원하는 것을 할 수 있으며, 일단 생성되면, 코드는 귀하의 책임이며 귀하가 적절하다고 생각되는 라이센스 용어에 따라 다릅니다.
Github 코드 검색
이 repo는 OpenAPI 생성기의 v6.2.0을 기반으로합니다. 이 프로젝트는 복잡한 사례 (하향식 접근법)에 중점을 둔 OpenAPI 3.1 사양의 일부로 JSON 스키마를 100% 준수하는 데 중점을 둡니다. 목표는 개발자가 JSON 스키마와 API 설계에서 OpenAPI 사양을 활용할 수 있도록 JSON 스키마에 정의 된 모든 것을 완전히 지원하는 것입니다. 여기에 구축하면 새로운 기능을 사용하지 않는 많은 구형 생성기를 지원하지 않고 OpenApi 3.x의 새로운 기능을 지원하는보다 빠른 발전이 가능합니다.
OpenApi JSON 스키마 생성기는 OpenAPI 생성기 v6.2.0을 기반으로합니다. 이 프로젝트는 OpenApi-Generator Core 팀이 프로젝트에서 Python Generator를 제거해야했기 때문에 여기에서 만들어졌습니다. Python Generator (@spacether)의 저자는 OpenApi-Generator Repo에서 계속 구축하는 것을 선호했지만 Core Team은 Python을 OpenApi-Generator에 유지하는 것을 고려하지 않았습니다. 아래는 해당 이벤트의 타임 라인과 그 이유 중 일부입니다.
Copyright 2023 Openapi-Json-Schema-Generator 기고자 Copyright 2018 OpenApi-Generator 기고자 (https://openapi-generator.tech) Copyright 2018 SmartBear Software
Apache 라이센스, 버전 2.0 ( "라이센스")에 따라 라이센스가 부여되었습니다. 라이센스를 준수하는 것 외에는이 파일을 사용할 수 없습니다. Apache.org/licenses/license-2.0에서 라이센스 사본을 얻을 수 있습니다.
해당 법률에 의해 요구되거나 서면에 동의하지 않는 한, 라이센스에 따라 배포 된 소프트웨어는 명시 적 또는 묵시적 보증 또는 조건없이 "그대로"기준으로 배포됩니다. 라이센스에 따른 특정 언어 통치 권한 및 제한 사항에 대한 라이센스를 참조하십시오.