{"id":14986583,"url":"https://github.com/ts-stack/openapi-spec","last_synced_at":"2025-04-11T20:31:53.636Z","repository":{"id":57167974,"uuid":"336538249","full_name":"ts-stack/openapi-spec","owner":"ts-stack","description":"OpenAPI Specification v3.1 writen in TypeScript.","archived":false,"fork":false,"pushed_at":"2024-09-27T13:59:36.000Z","size":418,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T04:05:52.741Z","etag":null,"topics":["open-api","open-api-specification","swagger"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ts-stack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-06T12:58:08.000Z","updated_at":"2024-09-27T13:59:39.000Z","dependencies_parsed_at":"2024-10-12T00:16:01.651Z","dependency_job_id":null,"html_url":"https://github.com/ts-stack/openapi-spec","commit_stats":{"total_commits":82,"total_committers":1,"mean_commits":82.0,"dds":0.0,"last_synced_commit":"476e6960df6022dc31fb24e4c45e54b25ba4f0fb"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":"ts-stack/starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-stack%2Fopenapi-spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-stack%2Fopenapi-spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-stack%2Fopenapi-spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-stack%2Fopenapi-spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts-stack","download_url":"https://codeload.github.com/ts-stack/openapi-spec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247934828,"owners_count":21020728,"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":["open-api","open-api-specification","swagger"],"created_at":"2024-09-24T14:13:10.794Z","updated_at":"2025-04-11T20:31:48.626Z","avatar_url":"https://github.com/ts-stack.png","language":"TypeScript","readme":"# About the project\n\n`@ts-stack/openapi-spec` has TypeScript models according to [OpenAPI Specification][1] v3.1.0.\nTo use it, required TypeScript v4.1+.\n\nMajor and minor versions of `@ts-stack/openapi-spec` are the same as [OpenAPI Specification][1],\nbut the patch version is not the same:\n\n| OpenAPI Specification   | @ts-stack/openapi-spec |\n|-------------------------|-------------------------|\n| v3.1.0                  | \u003cul\u003e\u003cli\u003ev3.1.0\u003c/li\u003e\u003cli\u003ev3.1.1\u003c/li\u003e\u003cli\u003ev3.1.2\u003c/li\u003e\u003cli\u003ev3.1.3\u003c/li\u003e\u003cli\u003ev3.1.4\u003c/li\u003e\u003cli\u003ev3.1.5\u003c/li\u003e\u003cli\u003ev3.1.6\u003c/li\u003e\u003c/ul\u003e |\n\n\n## Introduction\n\nThe OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs\nwhich allows both humans and computers to discover and understand the capabilities of the service\nwithout access to source code, documentation, or through network traffic inspection. When properly\ndefined, a consumer can understand and interact with the remote service with a minimal amount of\nimplementation logic.\n\nAn OpenAPI definition can then be used by documentation generation tools to display the API, code\ngeneration tools to generate servers and clients in various programming languages, testing tools,\nand many other use cases.\n\n## Install\n\n```bash\nnpm i -D @ts-stack/openapi-spec\n```\n\n## openapi version usage\n\nYou can use the `openapi` constant that contains the version of the OpenAPI Specification:\n\n```ts\nimport { openapi } from '@ts-stack/openapi-spec';\n\nconsole.log(openapi) // 3.1.0\n```\n\n## SpecificationExtension Usage\n\nIf you want to use already extended interfaces, you need to import interfaces with the `X` prefix:\n\n```ts\nimport { XOasObject } from '@ts-stack/openapi-spec';\n\nconst extendedOasObject: XOasObject\u003c'x-one' | 'x-two'\u003e = {\n  info: { title: '', version: '' },\n  openapi: '',\n  'x-one': '',\n  'x-two': '',\n};\n```\n\nOr, you can extends any of model in this way:\n\n```ts\nimport { OasObject, SpecificationExtension } from '@ts-stack/openapi-spec';\n\ntype ExtendedOasObject = OasObject \u0026 SpecificationExtension\u003c'x-one' | 'x-two'\u003e;\n\nconst extendedOasObject: ExtendedOasObject = {\n  info: { title: '', version: '' },\n  openapi: '',\n  'x-one': '',\n  'x-two': '',\n};\n```\n\nSame but with an interface to extends properties:\n\n```ts\nimport { OasObject, SpecificationExtension } from '@ts-stack/openapi-spec';\n\ninterface ExtendedProperties {\n  'x-one': any,\n  'x-two': any\n}\n\ntype ExtendedOasObject = OasObject \u0026 SpecificationExtension\u003ckeyof ExtendedProperties\u003e;\n\nconst extendedOasObject: ExtendedOasObject = {\n  info: {title: '', version: ''},\n  openapi: '',\n  'x-one': '',\n  'x-two': '',\n};\n```\n\n## PathsObject Usage\n\n```ts\nimport { PathsObject } from '@ts-stack/openapi-spec';\n\ntype Paths = '/one' | '/two';\n\ntype StrictDifinedPaths = PathsObject\u003cPaths\u003e;\n\nconst paths: StrictDifinedPaths = {\n  '/one': {},\n  '/two': {},\n};\n```\n\n\n[1]: https://github.com/OAI/OpenAPI-Specification\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-stack%2Fopenapi-spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts-stack%2Fopenapi-spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-stack%2Fopenapi-spec/lists"}