Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[![CI Tests](https://dl.circleci.com/status-badge/img/gh/openapi-json-schema-tools/openapi-json-schema-generator/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/openapi-json-schema-tools/openapi-json-schema-generator/tree/master)
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-orange)](./LICENSE)

Auto generate a client sdk from your openapi 3.0.0-3.0.3 document using Openapi JSON Schema Generator.
Auto generate a client sdk from your openapi 3.0.0-3.1.0 document using Openapi JSON Schema Generator.
This project is a code generator that focuses on supporting all openapi and json schema features.

## Overview
OpenAPI JSON Schema Generator allows auto-generation of API client libraries (SDK generation) given an
[OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (3.0.0-3.0.3 are supported).
[OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (3.0.0-[3.1.0*](#preliminary-310-spec-support) are supported).
This project focuses on making the output 100% compliant with openapi + JSON schema specs.
The goal is to fully support everything defined in openapi + the included JSON schema specs
so developers can use all of those features.
Expand All @@ -23,6 +23,7 @@ You can join us here: https://discord.gg/mHB8WEQuYQ

## Reasons To Use the Python Generator

- [3.1.0*](#preliminary-310-spec-support) - 3.0.0 spec support
- Type hints on
- schema payload inputs in SomeSchema.validate ![validate screen capture](docs/schema_validate.gif)
- Note: to make input dictionaries TypedDicts like the Money.validate example, set additionalProperties to false in the schema in your openapi document
Expand Down Expand Up @@ -58,8 +59,10 @@ And many more!
- [Docs for the python generator](docs/generators/python.md)
- [generated client sample code](samples/client/petstore/python)
- [Openapi v3.0.3 general petstore spec, general features](src/test/resources/3_0/python/petstore_customized.yaml)
- [generated client sample code](samples/client/3_0_3_unit_test/python)
- [generated v3.0.3 unit test client sample code](samples/client/3_0_3_unit_test/python)
- [Openapi json schema v3.0.3 unit test spec](src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml)
- [generated v3.1.0 unit test client sample code](samples/client/3_1_0_unit_test/python)
- [Openapi json schema v3.1.0 unit test spec](src/test/resources/3_1/unit_test_spec/3_1_0_unit_test_spec.yaml)

### Can I build here?

Expand Down Expand Up @@ -91,18 +94,34 @@ Submit a PR if you want to add a new server scaffold, client sdk, or documentati

The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The openapi-json-schema-generator project has the following compatibilities with the OpenAPI Specification:

| OpenAPI JSON Schema Generator Version | OpenAPI Spec compatibility |
|---------------------------------------|-----------------------------|
| 3.0.0 | 3.0.0 - 3.0.3 |
| 2.0.3 | 3.0.0 - 3.0.3 |
| 2.0.2 | 3.0.0 - 3.0.3 |
| 2.0.1 | 3.0.0 - 3.0.3 |
| 2.0.0 | 3.0.0 - 3.0.3 |
| 1.0.4 | 3.0.0 - 3.0.3 |
| 1.0.3 | 3.0.0 - 3.0.3 |
| 1.0.2 | 3.0.0 - 3.0.3 |
| 1.0.1 | 3.0.0 - 3.0.3 |
| 1.0.0 | 3.0.0 - 3.0.3 |
| OpenAPI JSON Schema Generator Version | OpenAPI Spec compatibility |
|---------------------------------------|--------------------------------------------------|
| 3.1.0 | 3.0.0 - [3.1.0*](#preliminary-310-spec-support) |
| 3.0.0 | 3.0.0 - 3.0.3 |
| 2.0.3 | 3.0.0 - 3.0.3 |
| 2.0.2 | 3.0.0 - 3.0.3 |
| 2.0.1 | 3.0.0 - 3.0.3 |
| 2.0.0 | 3.0.0 - 3.0.3 |
| 1.0.4 | 3.0.0 - 3.0.3 |
| 1.0.3 | 3.0.0 - 3.0.3 |
| 1.0.2 | 3.0.0 - 3.0.3 |
| 1.0.1 | 3.0.0 - 3.0.3 |
| 1.0.0 | 3.0.0 - 3.0.3 |

#### Preliminary 3.1.0 spec support
Preliminary 3.1.0 spec support includes these json schema keywords:
1. type (array of types supported in addition to one non-array value)
2. const: only string values are working because of bugs in swagger parser
3. contains
4. dependentRequired
5. dependentSchemas
6. maxContains
7. minContains
8. patternProperties
9. prefixItems
10. propertyNames
11. unevaluatedItems
12. unevaluatedProperties


### Build Projects
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
</dependencies>
<properties>
<!-- RELEASE_VERSION -->
<revision>3.0.0</revision>
<revision>3.1.0</revision>
<!-- /RELEASE_VERSION -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,6 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC =
"If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. " +
"If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.";
public static final String UNSUPPORTED_V310_SPEC_MSG =
"Generation using 3.1.0 specs is in development and is not officially supported yet. " +
"If you would like to expedite development, please consider woking on the open issues in the 3.1.0 project: https://github.com/orgs/openapi-json-schema-tools/projects/4 " +
"and reach out to our team on Discord at https://discord.gg/mHB8WEQuYQ";
public static final String ENUM_UNKNOWN_DEFAULT_CASE = "enumUnknownDefaultCase";
public static final String ENUM_UNKNOWN_DEFAULT_CASE_DESC =
"If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,6 @@ public void setOpenAPI(OpenAPI openAPI) {
int specMajorVersion = Integer.parseInt(originalSpecVersion.substring(0, 1));
int specMinorVersion = Integer.parseInt(originalSpecVersion.substring(2, 3));
boolean specVersionGreaterThanOrEqualTo310 = (specMajorVersion == 3 && specMinorVersion >= 1);
if (specVersionGreaterThanOrEqualTo310) {
LOGGER.warn(CodegenConstants.UNSUPPORTED_V310_SPEC_MSG);
}
this.openAPI = openAPI;
// Set global settings such that helper functions in ModelUtils can look up the value
// of the CLI option.
Expand Down