{"id":24698571,"url":"https://github.com/faradayio/openapi-interfaces","last_synced_at":"2026-05-09T16:04:15.293Z","repository":{"id":37792978,"uuid":"408960929","full_name":"faradayio/openapi-interfaces","owner":"faradayio","description":"Extend OpenAPI with support for interfaces and automatic generation of related types like MergePatch. Compile to plain OpenAPI.","archived":false,"fork":false,"pushed_at":"2023-06-29T20:51:56.000Z","size":140,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-11T01:06:04.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faradayio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-21T20:11:52.000Z","updated_at":"2021-10-05T17:55:29.000Z","dependencies_parsed_at":"2024-11-14T14:02:41.045Z","dependency_job_id":null,"html_url":"https://github.com/faradayio/openapi-interfaces","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.10909090909090913","last_synced_commit":"20db7da60ac14d9e2a85a550848cb3106208b585"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/faradayio/openapi-interfaces","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faradayio%2Fopenapi-interfaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faradayio%2Fopenapi-interfaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faradayio%2Fopenapi-interfaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faradayio%2Fopenapi-interfaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faradayio","download_url":"https://codeload.github.com/faradayio/openapi-interfaces/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faradayio%2Fopenapi-interfaces/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265086953,"owners_count":23709331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-27T04:29:20.654Z","updated_at":"2025-10-20T04:50:51.483Z","avatar_url":"https://github.com/faradayio.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `openapi-interfaces`: Automatically generate `GET`, `POST`, `PUT` and JSON Merge Patch schemas for OpenAPI\n\n**EXPERIMENTAL.** Details subject to change.\n\nThis tool extends [OpenAPI 3.1.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) with the ability to generate related schemas automatically. Specifically, you can define a single interface type `Widget`, and automatically generate:\n\n- `Widget` (for `GET` requests)\n- `WidgetPost`\n- `WidgetPut`\n- `WidgetMergePatch` (for `PATCH` requests using [JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7396) format, which is basically a nicely formalized \"partial `PUT`\")\n\n## Installation\n\nTo install the latest version, first make sure you have a Rust toolchain. You\ncan [install one using these instructions](https://rustup.rs/). Then run:\n\n```sh\ncargo install -f openapi-interfaces\n```\n\nWe will provide binaries at some point.\n\n## Usage\n\n```sh\nopenapi-interfaces --help\nopenapi-interfaces api_with_interfaces.yml -o api.yml\n```\n\n## OpenAPI extensions\n\nThis tool defines a new `components.interfaces` section, which allows specifying \"interface\" types. For example:\n\n```yaml\ncomponents:\n  # You can declare schemas normally if you wish.\n  schemas: {}\n\n  # But we also support interface definitions.\n  interfaces:\n    Resource:\n      emit: false # Do not include this in generated output.\n      members:\n        id:\n          required: true\n          schema:\n            # Normal OpenAPI / JSON Schema definitions.\n            type: string\n            format: uuid\n    Widget:\n      # Include all fields from `Resource`.\n      $includes: \"Resource\"\n      members:\n        # We can override properties from `Resource` using JSON\n        # Merge Patch syntax.\n        id:\n          schema:\n            example: e35a3c8d-5486-49ec-9b23-6747afc19570\n        name:\n          required: true\n          mutable: true\n          schema:\n            type: string\n        comment:\n          mutable: true\n          schema:\n            type: string\n        readonly:\n          required: true\n          # This can't be updated once the object is created.\n          mutable: false\n          # But we do allow this to be set at creation time.\n          # If omitted, `initializable` defaults to the value\n          # of the `mutable` option.\n          initializable: true\n          schema:\n            type: string\n```\n\nThis will automatically generate four `Widget` types:\n\n```yaml\ncomponents:\n  schemas:\n    Widget: ...\n    WidgetPost: ...\n    WidgetPut: ...\n    WidgetMergePatch: ...\n```\n\nFor the complete definitions, see [`example_output.yml`](./examples/example_output.yml).\n\n### Referring to interfaces\n\nWe can then refer to interfaces using the new `$interface` key, with an appropriate variant:\n\n```yaml\npaths:\n  /widgets:\n    post:\n      requestBody:\n        required: true\n        content:\n          application/json:\n              schema:\n                # This becomes `$ref: \"#/components/schemas/WidgetPost`.\n                $interface: \"Widget#Post\"\n      responses:\n        201:\n          content:\n            application/json:\n              schema:\n                # This becomes `$ref: \"#/components/schemas/Widget`.\n                $interface: \"Widget\"\n```\n\nPossible options are:\n\n- `Widget`: The type returned by `GET` and other methods that provide a complete resource from the server.\n- `Widget#Post`: The type passed to a `POST` request.\n- `Widget#Put`: The type passed to a `PUT` request. May also be used as the base type for applying `#MergePatch` values.\n- `Widget#MergePatch`: A [JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7396) schema that can be passed to `PATCH`.\n- `Widget#SameAsInterface`: **May only be used inside `components.interfaces`.** This is a shortcut value that says \"When generating a `#Get` interface, include `$ref: \"components.schemas.Widget`. When generating a `#Post` interface, include `$ref: \"components.schemas.WidgetPost`.\" In other words, use the same variant selector as the containing interface. Useful for when compound types are sent over the wire.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaradayio%2Fopenapi-interfaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaradayio%2Fopenapi-interfaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaradayio%2Fopenapi-interfaces/lists"}