🎉 Tool for generation catalog schema from OpenAPI definition file (#5734)
* Add tool for generating catalog json schema from openapi definition file
This commit is contained in:
@@ -9,6 +9,9 @@ The schema of a stream is the return value of `Stream.get_json_schema`.
|
||||
By default, `Stream.get_json_schema` reads a `.json` file in the `schemas/` directory whose name is equal to the value of the `Stream.name` property. In turn `Stream.name` by default returns the name of the class in snake case. Therefore, if you have a class `class EmployeeBenefits(HttpStream)` the default behavior will look for a file called `schemas/employee_benefits.json`. You can override any of these behaviors as you need.
|
||||
|
||||
Important note: any objects referenced via `$ref` should be placed in the `shared/` directory in their own `.json` files.
|
||||
|
||||
### Generating schemas from OpenAPI definitions
|
||||
If you are implementing a connector to pull data from an API which publishes an [OpenAPI/Swagger spec](https://swagger.io/specification/), you can use a tool we've provided for generating JSON schemas from the OpenAPI definition file. Detailed information can be found [here](https://github.com/airbytehq/airbyte/tree/master/tools/openapi2jsonschema/).
|
||||
|
||||
## Dynamic schemas
|
||||
If you'd rather define your schema in code, override `Stream.get_json_schema` in your stream class to return a `dict` describing the schema using [JSONSchema](https://json-schema.org).
|
||||
@@ -21,3 +24,4 @@ def get_json_schema(self):
|
||||
schema['dynamically_determined_property'] = "property"
|
||||
return schema
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user