{"id":17159892,"url":"https://github.com/nxht/typebox-extended-openapi","last_synced_at":"2026-02-18T15:31:08.131Z","repository":{"id":253923028,"uuid":"844934989","full_name":"nxht/typebox-extended-openapi","owner":"nxht","description":"Collection of custom typebox schema for OpenAPI","archived":false,"fork":false,"pushed_at":"2025-01-10T13:00:17.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T21:57:19.899Z","etag":null,"topics":["typebox","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@nxht/typebox-extended-openapi","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nxht.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-08-20T08:58:46.000Z","updated_at":"2025-01-10T13:00:20.000Z","dependencies_parsed_at":"2025-04-13T14:07:09.992Z","dependency_job_id":"9f9e2e91-2376-498a-8aa2-86c76bf5572e","html_url":"https://github.com/nxht/typebox-extended-openapi","commit_stats":null,"previous_names":["nxht/typebox-extended-openapi"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/nxht/typebox-extended-openapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxht%2Ftypebox-extended-openapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxht%2Ftypebox-extended-openapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxht%2Ftypebox-extended-openapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxht%2Ftypebox-extended-openapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nxht","download_url":"https://codeload.github.com/nxht/typebox-extended-openapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxht%2Ftypebox-extended-openapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29583916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T13:56:48.962Z","status":"ssl_error","status_checked_at":"2026-02-18T13:54:34.145Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["typebox","typescript"],"created_at":"2024-10-14T22:15:27.468Z","updated_at":"2026-02-18T15:31:08.114Z","avatar_url":"https://github.com/nxht.png","language":"TypeScript","readme":"# Typebox Extended for OpenAPI\n\nCollection of custom [@sinclair/typebox](https://github.com/sinclairzx81/typebox) schema, primarily for OpenAPI specification.\n\n## Install \n```bash\n$ npm install @nxht/typebox-extended-openapi\n```\n## Types\n\n\n### StringEnum\n\nSimilar to `Type.Enum` but\n- Only accepts string.\n- Uses JSONSchema `enum` keyword instead of `anyOf` for OpenAPI compatibility.\n- Unlike using [Type.Unsafe](https://github.com/sinclairzx81/typebox?tab=readme-ov-file#unsafe-types), this validates if the value is in the enum list.\n\n```ts\nimport { TypeX, TypeXGuard } from '@nxht/typebox-extended-openapi';\nimport { Value } from '@sinclair/typebox/value';\n\nconst T = TypeX.StringEnum(['a', 'b', 'c']);\n// Json Schema\n// const T = {\n//   type: \"string\",\n//   enum: [ \"a\", \"b\", \"c\" ],\n// }\n\ntype T = Static\u003ctypeof T\u003e;\n// type T = 'a' | 'b' | 'c'\n\nValue.Check(T, 'a') // true\nValue.Check(T, 'd') // false\n\n// TypeGuard for StringEnum\nTypeXGuard.IsStringEnum(T); // true\n```\n\n### StringWithAutoComplete\n\nSimilar to `TypeX.StringEnum` but doesn't validate if the value is in the enum list.\n\n```ts\nimport { TypeX, TypeXGuard } from '@nxht/typebox-extended-openapi';\n\nconst T = TypeX.StringWithAutoComplete(['a', 'b', 'c']);\n// Json Schema\n// const T = {\n//   type: \"string\",\n//   enum: [ \"a\", \"b\", \"c\" ],\n// }\n\ntype T = Static\u003ctypeof T\u003e;\n// type T = \"a\" | \"b\" | \"c\" | (string \u0026 {})\n\nValue.Check(T, 'a') // true\nValue.Check(T, 'd') // true\n```\n\n\n### Nullable\n\n- Makes a schema nullable\n- Unlike `Type.Union([Type.Null(), schema])`, this emit JSONSchema `nullable: true` instead of using `anyOf`\n- Unlike using [Type.Unsafe](https://github.com/sinclairzx81/typebox?tab=readme-ov-file#unsafe-types), this schema doesn't emit error if the value is null\n\n#### Known limitations\n- `TypeGuard` doesn't work as this has `Nullable` schema type\n\n```ts\nimport { TypeX, TypeXGuard } from '@nxht/typebox-extended-openapi';\nimport { Value } from '@sinclair/typebox/value';\n\nconst T = TypeX.Nullable(Type.String());\n// Json Schema\n// const T = {\n//   type: \"string\",\n//   nullable: true\n// }\n\ntype T = Static\u003ctypeof T\u003e;\n// type T = string | null\n\nValue.Check(T, 'a') // true\nValue.Check(T, null) // true\nValue.Check(T,  1) // false\n```\n\n\n### Merge\n\nMerge multiple Typebox schema into one\n- Unlike `Type.Intersect` or `Type.Composite`, if there's key conflict, the right-most schema will be used.\n- Unlike `Type.Intersect`, the result schema will have merged properties instead of `allOf` which could be better for OpenAPI specification readability.\n- Much faster type inference than `Type.Composite` especially for large object.\n\n```ts\nimport { Type, type Static } from '@sinclair/typebox';\nimport { TypeX } from '@nxht/typebox-extended-openapi';\n\nconst A = Type.Object({\n  a: Type.Union([Type.String(), Type.Number()]),\n}); \n// type A = { a: string | number }\nconst B = Type.Object({\n  a: Type.Union([Type.String(), Type.Boolean()]),\n  b: Type.String(),\n});\n// type B = { a: string | boolean, b: string }\n\nconst TIntersect = Type.Intersect([A, B]);\ntype TIntersect = Static\u003ctypeof TIntersect\u003e;\n// type TIntersect = { a: string | number } \u0026 { a: string | boolean, b: string } \n\nconst TComposite = Type.Composite([A, B]);\ntype TComposite = Static\u003ctypeof TComposite\u003e;\n// type TIntersect = { a: string, b: string }\n\nconst TMerge = TypeX.Merge([A, B]);\ntype TMerge = Static\u003ctypeof TMerge\u003e;\n// type TIntersect = { a: string | boolean, b: string }\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxht%2Ftypebox-extended-openapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnxht%2Ftypebox-extended-openapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxht%2Ftypebox-extended-openapi/lists"}