{ "module": "react-openapi", "content": { "path": "react-openapi", "docstring": "`react-openapi` - a spec-driven admin UI for OpenAPI/REST backends.\r\n\r\nPoint it at an OpenAPI document and it derives a full CRUD admin (list,\r\ndetail, create/edit, filtering, FK selects, streaming views) from the paths\r\nand schemas, plus optional profile screens and auth wiring. No per-resource\r\nhand-written screens are required.\r\n\r\n# Quick start\r\n\r\n```tsx\r\nimport { AppProvider, Admin } from \"react-openapi\";\r\n\r\n\r\n \r\n\r\n```\r\n\r\n# How it works\r\n\r\n- `AppProvider` loads the spec, validates it, builds a `ResourceConfig` per\r\n collection, parses `x-profile` operations, derives auth endpoints and\r\n initializes the shared axios client.\r\n- `useAppContext` exposes that state; `useResource(name)` adds CRUD helpers\r\n and filter widgets for one resource.\r\n- `Admin` renders the sidebar + routes; the field renderers\r\n (`ListCellRenderer`, `DetailFieldRenderer`, `FormFieldRenderer`) turn each\r\n `FieldConfig` into the right UI; `SseStreamView` renders live streams.\r\n\r\n# Spec extensions\r\n\r\n- `x-primary-key`, `x-display-format`, `x-list-columns`, `x-order`,\r\n `x-label`, `x-description`, `x-hidden`, `x-filterable`, `x-sortable`,\r\n `x-ui-type`, `x-edit-as`, `x-autocomplete`\r\n- `x-fk` (foreign keys), inline `$ref`/`oneOf` object handling\r\n- `x-upload`/`x-upload-url` (file/image fields)\r\n- `x-sse` (streaming collections)\r\n- `x-profile` (current-user operations)\r\n- `securitySchemes.bearerAuth` `x-server-url`, `x-login-path`,\r\n `x-register-path`, `x-logout-path`, `x-me-path`, `x-introspect-path`\r\n\r\n# Notes\r\n\r\n- Requires React 18, React Router and MUI (all peer/consumed deps).\r\n- `Admin` and `ProfileRoutes` must be nested inside an `AppProvider` and a\r\n router.", "objects": { "AdminProps": { "name": "AdminProps", "kind": "interface", "path": "react-openapi.AdminProps", "signature": "AdminProps", "docstring": "Props for `Admin`.", "members": { "basePath": { "name": "basePath", "kind": "property", "path": "react-openapi.AdminProps.basePath", "signature": "basePath: string", "docstring": "Base path the admin routes are mounted under, e.g. `\"/admin\"`." } } }, "AuthConfig": { "name": "AuthConfig", "kind": "interface", "path": "react-openapi.AuthConfig", "signature": "AuthConfig", "docstring": "Auth server config extracted from `securitySchemes` extensions.", "members": { "introspectPath": { "name": "introspectPath", "kind": "property", "path": "react-openapi.AuthConfig.introspectPath", "signature": "introspectPath: string", "docstring": "Token introspection endpoint path." }, "loginPath": { "name": "loginPath", "kind": "property", "path": "react-openapi.AuthConfig.loginPath", "signature": "loginPath: string", "docstring": "Login endpoint path." }, "logoutPath": { "name": "logoutPath", "kind": "property", "path": "react-openapi.AuthConfig.logoutPath", "signature": "logoutPath: string", "docstring": "Logout endpoint path." }, "mePath": { "name": "mePath", "kind": "property", "path": "react-openapi.AuthConfig.mePath", "signature": "mePath: string", "docstring": "\"Current user\" endpoint path." }, "registerPath": { "name": "registerPath", "kind": "property", "path": "react-openapi.AuthConfig.registerPath", "signature": "registerPath: string", "docstring": "Registration endpoint path." }, "serverUrl": { "name": "serverUrl", "kind": "property", "path": "react-openapi.AuthConfig.serverUrl", "signature": "serverUrl: string", "docstring": "Base URL of the auth server." } } }, "FieldConfig": { "name": "FieldConfig", "kind": "interface", "path": "react-openapi.FieldConfig", "signature": "FieldConfig", "docstring": "Resolved metadata for a single field, used by the list, form and detail\nrenderers and by the filter bar.", "members": { "autocomplete": { "name": "autocomplete", "kind": "property", "path": "react-openapi.FieldConfig.autocomplete", "signature": "autocomplete: \"text\" | \"token\" | \"email\" | \"phone\"", "docstring": "Server-side filter widget hint (`text`/`token`/`email`/`phone`)." }, "defaultValue": { "name": "defaultValue", "kind": "property", "path": "react-openapi.FieldConfig.defaultValue", "signature": "defaultValue: any", "docstring": "Schema-level `default` used to seed create-form state." }, "description": { "name": "description", "kind": "property", "path": "react-openapi.FieldConfig.description", "signature": "description: string", "docstring": "Description, if provided in the schema." }, "discriminatorProperty": { "name": "discriminatorProperty", "kind": "property", "path": "react-openapi.FieldConfig.discriminatorProperty", "signature": "discriminatorProperty: string", "docstring": "Property name that discriminates a `oneOf` field." }, "editAs": { "name": "editAs", "kind": "property", "path": "react-openapi.FieldConfig.editAs", "signature": "editAs: string", "docstring": "`x-edit-as: date` - edit a `date-time` field with a plain date input; submits midnight." }, "enumValues": { "name": "enumValues", "kind": "property", "path": "react-openapi.FieldConfig.enumValues", "signature": "enumValues: string[]", "docstring": "Allowed values for enum fields." }, "filterable": { "name": "filterable", "kind": "property", "path": "react-openapi.FieldConfig.filterable", "signature": "filterable: boolean", "docstring": "Whether the field can be filtered (`x-filterable`)." }, "fk": { "name": "fk", "kind": "property", "path": "react-openapi.FieldConfig.fk", "signature": "fk: FKFieldConfig", "docstring": "Foreign-key relationship, if this field references another resource." }, "format": { "name": "format", "kind": "property", "path": "react-openapi.FieldConfig.format", "signature": "format: string", "docstring": "OpenAPI `format` (`\"date\"`, `\"date-time\"`, `\"email\"`, ...)." }, "hidden": { "name": "hidden", "kind": "property", "path": "react-openapi.FieldConfig.hidden", "signature": "hidden: { detail: boolean; form: boolean; list: boolean }", "docstring": "Where the field is hidden." }, "inlineDisplayFormat": { "name": "inlineDisplayFormat", "kind": "property", "path": "react-openapi.FieldConfig.inlineDisplayFormat", "signature": "inlineDisplayFormat: string", "docstring": "Display template for inline references." }, "isArray": { "name": "isArray", "kind": "property", "path": "react-openapi.FieldConfig.isArray", "signature": "isArray: boolean", "docstring": "Whether the value is an array." }, "label": { "name": "label", "kind": "property", "path": "react-openapi.FieldConfig.label", "signature": "label: string", "docstring": "Display label (`x-label`)." }, "name": { "name": "name", "kind": "property", "path": "react-openapi.FieldConfig.name", "signature": "name: string", "docstring": "Property name in the schema." }, "oneOfOptions": { "name": "oneOfOptions", "kind": "property", "path": "react-openapi.FieldConfig.oneOfOptions", "signature": "oneOfOptions: OneOfOption[]", "docstring": "Branches for discriminated-union fields." }, "order": { "name": "order", "kind": "property", "path": "react-openapi.FieldConfig.order", "signature": "order: number", "docstring": "Sort order (`x-order`)." }, "readOnly": { "name": "readOnly", "kind": "property", "path": "react-openapi.FieldConfig.readOnly", "signature": "readOnly: boolean", "docstring": "Whether the field is read-only." }, "refSchema": { "name": "refSchema", "kind": "property", "path": "react-openapi.FieldConfig.refSchema", "signature": "refSchema: string", "docstring": "Schema name for inline (non-FK) object references." }, "required": { "name": "required", "kind": "property", "path": "react-openapi.FieldConfig.required", "signature": "required: boolean", "docstring": "Whether the field is required." }, "sortable": { "name": "sortable", "kind": "property", "path": "react-openapi.FieldConfig.sortable", "signature": "sortable: boolean", "docstring": "Whether the list can be sorted by this field." }, "type": { "name": "type", "kind": "property", "path": "react-openapi.FieldConfig.type", "signature": "type: string", "docstring": "OpenAPI type (`\"string\"`, `\"integer\"`, `\"object\"`, ...)." }, "uiType": { "name": "uiType", "kind": "property", "path": "react-openapi.FieldConfig.uiType", "signature": "uiType: string", "docstring": "UI-type override such as `\"currency\"` or `\"image\"`." }, "upload": { "name": "upload", "kind": "property", "path": "react-openapi.FieldConfig.upload", "signature": "upload: { type: string; url: string }", "docstring": "Parsed upload config (`{ type, url }`)." }, "uploadUrl": { "name": "uploadUrl", "kind": "property", "path": "react-openapi.FieldConfig.uploadUrl", "signature": "uploadUrl: string", "docstring": "Upload endpoint for file/image fields." } } }, "FilterComponentProps": { "name": "FilterComponentProps", "kind": "interface", "path": "react-openapi.FilterComponentProps", "signature": "FilterComponentProps", "docstring": "Props passed to a filter widget produced by `useResource().components`.", "members": { "data": { "name": "data", "kind": "property", "path": "react-openapi.FilterComponentProps.data", "signature": "data: any[]", "docstring": "The current page of rows (used by client-mode suggestions)." }, "labelOverride": { "name": "labelOverride", "kind": "property", "path": "react-openapi.FilterComponentProps.labelOverride", "signature": "labelOverride: string", "docstring": "Overrides the field's label for this filter widget." }, "onChange": { "name": "onChange", "kind": "property", "path": "react-openapi.FilterComponentProps.onChange", "signature": "onChange: void", "docstring": "Called with the updated filter value." }, "value": { "name": "value", "kind": "property", "path": "react-openapi.FilterComponentProps.value", "signature": "value: string", "docstring": "Current filter value (comma-joined for multi-value filters)." } } }, "FKFieldConfig": { "name": "FKFieldConfig", "kind": "interface", "path": "react-openapi.FKFieldConfig", "signature": "FKFieldConfig", "docstring": "Parsed `x-fk` configuration describing a foreign-key field.", "members": { "prefetch": { "name": "prefetch", "kind": "property", "path": "react-openapi.FKFieldConfig.prefetch", "signature": "prefetch: boolean", "docstring": "Load options eagerly instead of on field open." }, "resource": { "name": "resource", "kind": "property", "path": "react-openapi.FKFieldConfig.resource", "signature": "resource: string", "docstring": "Target resource name (must exist as a collection in the spec)." }, "value": { "name": "value", "kind": "property", "path": "react-openapi.FKFieldConfig.value", "signature": "value: string", "docstring": "Target property used as the wire value (defaults to the target's primary key)." } } }, "FkOption": { "name": "FkOption", "kind": "interface", "path": "react-openapi.FkOption", "signature": "FkOption", "docstring": "A single option for a foreign-key select.", "members": { "label": { "name": "label", "kind": "property", "path": "react-openapi.FkOption.label", "signature": "label: string", "docstring": "Human-readable label (target `x-display-format`)." }, "value": { "name": "value", "kind": "property", "path": "react-openapi.FkOption.value", "signature": "value: any", "docstring": "Wire value sent to the API (target primary key, or `x-fk.value`)." } } }, "ProfileComponents": { "name": "ProfileComponents", "kind": "interface", "path": "react-openapi.ProfileComponents", "signature": "ProfileComponents", "docstring": "Components used to render the `x-profile: true` operations.\n\nSupply any subset; a mode with no component renders nothing for that route.", "members": { "create": { "name": "create", "kind": "property", "path": "react-openapi.ProfileComponents.create", "signature": "create: React.ComponentType", "docstring": "Rendered for profile \"create\" operations (if any)." }, "edit": { "name": "edit", "kind": "property", "path": "react-openapi.ProfileComponents.edit", "signature": "edit: React.ComponentType", "docstring": "Rendered for profile \"edit\" operations (PUT/PATCH)." }, "view": { "name": "view", "kind": "property", "path": "react-openapi.ProfileComponents.view", "signature": "view: React.ComponentType", "docstring": "Rendered for profile \"view\" operations (GET)." } } }, "ProfileOperation": { "name": "ProfileOperation", "kind": "interface", "path": "react-openapi.ProfileOperation", "signature": "ProfileOperation", "docstring": "Represents a single operation marked with `x-profile: true` in the spec.", "members": { "method": { "name": "method", "kind": "property", "path": "react-openapi.ProfileOperation.method", "signature": "method: string", "docstring": "HTTP method in upper case, e.g. `\"GET\"`." }, "operationId": { "name": "operationId", "kind": "property", "path": "react-openapi.ProfileOperation.operationId", "signature": "operationId: string", "docstring": "`operationId` from the spec." }, "path": { "name": "path", "kind": "property", "path": "react-openapi.ProfileOperation.path", "signature": "path: string", "docstring": "Spec path template, e.g. `\"/users/me\"`." }, "summary": { "name": "summary", "kind": "property", "path": "react-openapi.ProfileOperation.summary", "signature": "summary: string", "docstring": "Human-readable summary, when present." } } }, "ProfileRoute": { "name": "ProfileRoute", "kind": "interface", "path": "react-openapi.ProfileRoute", "signature": "ProfileRoute", "docstring": "A route describing a profile screen, derived from an `x-profile` operation.", "members": { "method": { "name": "method", "kind": "property", "path": "react-openapi.ProfileRoute.method", "signature": "method: string", "docstring": "HTTP method in upper case, e.g. `\"GET\"`." }, "operationId": { "name": "operationId", "kind": "property", "path": "react-openapi.ProfileRoute.operationId", "signature": "operationId: string", "docstring": "`operationId` from the spec." }, "path": { "name": "path", "kind": "property", "path": "react-openapi.ProfileRoute.path", "signature": "path: string", "docstring": "Spec path template, e.g. `\"/users/me\"`." }, "summary": { "name": "summary", "kind": "property", "path": "react-openapi.ProfileRoute.summary", "signature": "summary: string", "docstring": "Human-readable summary, when present." } } }, "ResourceConfig": { "name": "ResourceConfig", "kind": "interface", "path": "react-openapi.ResourceConfig", "signature": "ResourceConfig", "docstring": "Fully resolved metadata for one resource, derived from the OpenAPI paths\nand schemas. This is the object every list/form/detail view is driven by.", "members": { "displayFormat": { "name": "displayFormat", "kind": "property", "path": "react-openapi.ResourceConfig.displayFormat", "signature": "displayFormat: string", "docstring": "Template used to render a row/item title (`x-display-format`)." }, "displayName": { "name": "displayName", "kind": "property", "path": "react-openapi.ResourceConfig.displayName", "signature": "displayName: string", "docstring": "Human-friendly label used in navigation and titles." }, "fields": { "name": "fields", "kind": "property", "path": "react-openapi.ResourceConfig.fields", "signature": "fields: FieldConfig[]", "docstring": "All fields, sorted by `x-order` then name." }, "listColumns": { "name": "listColumns", "kind": "property", "path": "react-openapi.ResourceConfig.listColumns", "signature": "listColumns: string[]", "docstring": "Columns shown in the list view (`x-list-columns`)." }, "name": { "name": "name", "kind": "property", "path": "react-openapi.ResourceConfig.name", "signature": "name: string", "docstring": "Resource name (path segment), e.g. `\"expenses\"`." }, "operations": { "name": "operations", "kind": "property", "path": "react-openapi.ResourceConfig.operations", "signature": "operations: { create: boolean; delete: boolean; get: boolean; list: boolean; patch: boolean; update: boolean }", "docstring": "Which CRUD operations the spec exposes." }, "orderedFields": { "name": "orderedFields", "kind": "property", "path": "react-openapi.ResourceConfig.orderedFields", "signature": "orderedFields: FieldConfig[]", "docstring": "Fields in `fields` restricted to those with a defined order." }, "pagination": { "name": "pagination", "kind": "property", "path": "react-openapi.ResourceConfig.pagination", "signature": "pagination: null | { defaultLimit: number; limitParam: string; offsetParam: string }", "docstring": "Pagination contract, or `null` when the collection is not paginated." }, "parent": { "name": "parent", "kind": "property", "path": "react-openapi.ResourceConfig.parent", "signature": "parent: { pathParam: string; resource: string }", "docstring": "Set when this is a sub-resource (nested under a parent resource)." }, "path": { "name": "path", "kind": "property", "path": "react-openapi.ResourceConfig.path", "signature": "path: string", "docstring": "Base API path for the collection, e.g. `\"/expenses\"`." }, "primaryKey": { "name": "primaryKey", "kind": "property", "path": "react-openapi.ResourceConfig.primaryKey", "signature": "primaryKey: string", "docstring": "Primary-key property name (`x-primary-key`)." }, "relationships": { "name": "relationships", "kind": "property", "path": "react-openapi.ResourceConfig.relationships", "signature": "relationships: ResourceRelationship[]", "docstring": "Foreign-key relationships for this resource." }, "schemaName": { "name": "schemaName", "kind": "property", "path": "react-openapi.ResourceConfig.schemaName", "signature": "schemaName: string", "docstring": "Schema name used for display and lookups." }, "streaming": { "name": "streaming", "kind": "property", "path": "react-openapi.ResourceConfig.streaming", "signature": "streaming: boolean", "docstring": "`true` when the collection is an `x-sse` event stream." }, "subResources": { "name": "subResources", "kind": "property", "path": "react-openapi.ResourceConfig.subResources", "signature": "subResources: string[]", "docstring": "Names of nested sub-resources." }, "updateMethod": { "name": "updateMethod", "kind": "property", "path": "react-openapi.ResourceConfig.updateMethod", "signature": "updateMethod: \"put\" | \"patch\"", "docstring": "Whether updates use `PUT` or `PATCH`." } } }, "ResourceRelationship": { "name": "ResourceRelationship", "kind": "interface", "path": "react-openapi.ResourceRelationship", "signature": "ResourceRelationship", "docstring": "A foreign-key relationship derived from a `x-fk` field, linking this\nresource to another resource.", "members": { "config": { "name": "config", "kind": "property", "path": "react-openapi.ResourceRelationship.config", "signature": "config: FKFieldConfig", "docstring": "Parsed `x-fk` configuration." }, "fieldName": { "name": "fieldName", "kind": "property", "path": "react-openapi.ResourceRelationship.fieldName", "signature": "fieldName: string", "docstring": "Name of the FK field on this resource." }, "targetSchemaName": { "name": "targetSchemaName", "kind": "property", "path": "react-openapi.ResourceRelationship.targetSchemaName", "signature": "targetSchemaName: string", "docstring": "Name of the target resource schema." } } }, "SpecConfiguration": { "name": "SpecConfiguration", "kind": "interface", "path": "react-openapi.SpecConfiguration", "signature": "SpecConfiguration", "docstring": "Top-level configuration passed to `AppProvider`.\n\nDescribes where to load the OpenAPI document and how to talk to the API and\nauth server. See the README for the spec extensions react-openapi expects\n(`x-primary-key`, `x-display-format`, `x-list-columns`, `x-order`,\n`x-label`, `x-fk`, `x-sse`, `x-profile`, ...).", "members": { "baseApiUrl": { "name": "baseApiUrl", "kind": "property", "path": "react-openapi.SpecConfiguration.baseApiUrl", "signature": "baseApiUrl: string", "docstring": "Base URL of the API; defaults to the spec's first `servers[].url`." }, "getToken": { "name": "getToken", "kind": "property", "path": "react-openapi.SpecConfiguration.getToken", "signature": "getToken: null | string", "docstring": "Called to obtain the current bearer token for API requests." }, "profileComponents": { "name": "profileComponents", "kind": "property", "path": "react-openapi.SpecConfiguration.profileComponents", "signature": "profileComponents: ProfileComponents", "docstring": "Components for `x-profile` operations (profile view/edit/create)." }, "resourceConfig": { "name": "resourceConfig", "kind": "property", "path": "react-openapi.SpecConfiguration.resourceConfig", "signature": "resourceConfig: Record", "docstring": "Per-resource UI overrides keyed by resource name." }, "specUrl": { "name": "specUrl", "kind": "property", "path": "react-openapi.SpecConfiguration.specUrl", "signature": "specUrl: string", "docstring": "URL of the OpenAPI JSON/YAML document to load." }, "title": { "name": "title", "kind": "property", "path": "react-openapi.SpecConfiguration.title", "signature": "title: string", "docstring": "Overrides the app/site title shown in the layout." } } }, "FkResolver": { "name": "FkResolver", "kind": "type-alias", "path": "react-openapi.FkResolver", "signature": "FkResolver: Promise", "docstring": "Resolve a foreign-key wire value (e.g. an id) to the object to send.\n\n**Parameters:**\n\n- `resourceName` — The target resource name.\n- `fkValue` — The FK value to resolve.\n\n**Returns:**\n\nThe resolved object (or the original value when unresolved)." }, "Admin": { "name": "Admin", "kind": "component", "path": "react-openapi.Admin", "signature": "Admin(__namedParameters: AdminProps): React.JSX.Element", "docstring": "Root admin UI driven entirely by the loaded OpenAPI spec.\r\n\r\nReads resources from `useAppContext` and renders a `Layout` with a\r\n`SideMenu` plus nested routes per resource:\r\n`//` (list), `//new` (create),\r\n`//:id` (detail) and `//:id/edit`. Streaming (`x-sse`)\r\nresources render only the list. While the spec is loading it shows a\r\nspinner; spec validation errors are shown via `ValidationAlert`; warnings\r\nare shown as a dismissible alert above the layout.\r\n\r\nNotes:\r\n- Must be rendered inside an `AppProvider` and a router.\r\n- The index route redirects to the first top-level resource.\r\n\r\nProps: see `AdminProps`.\n\n**Example:**\n\n```tsx\r\n} />\r\n```" }, "applyDisplayFormat": { "name": "applyDisplayFormat", "kind": "function", "path": "react-openapi.applyDisplayFormat", "signature": "applyDisplayFormat(item: any, format: string): string", "docstring": "Render an item through a `{prop}` display template.\r\n\r\nReplaces each `{a.b}` placeholder with the (dot-path) nested value, formatted\r\nwith `formatIsoLike`. Non-object `item`s are stringified directly.\n\n**Parameters:**\n\n- `item` — The record to format.\n- `format` — Template such as `\"{first_name} {last_name}\"`.\n\n**Returns:**\n\nThe formatted string." }, "AppProvider": { "name": "AppProvider", "kind": "component", "path": "react-openapi.AppProvider", "signature": "AppProvider(__namedParameters: AppProviderProps): React.FunctionComponentElement>", "docstring": "Load an OpenAPI spec and provide the derived app model to the tree.\r\n\r\nOn mount (and whenever `specConfiguration.specUrl` changes) it:\r\n1. Loads the spec (`loadSpec`).\r\n2. Validates it (`validateSpec`), collecting `errors` and `warnings`.\r\n3. If there are no errors, builds `resources` (`buildResourceConfigs`),\r\n applies per-resource `fieldTypes` overrides, and initializes the shared\r\n axios client via `initApi(baseApiUrl, getToken)`.\r\n\r\nIt also derives `authConfig` (from `securitySchemes.bearerAuth` `x-*`\r\nextensions) and `profileOperations` (operations flagged `x-profile: true`),\r\nand exposes everything through `AppContext` for `useAppContext`, `Admin`,\r\nand `ProfileRoutes`.\r\n\r\nNotes:\r\n- Must wrap any component that uses `useAppContext`, `Admin`, `useResource`\r\n or the profile screens.\r\n- Base API URL precedence: `specConfiguration.baseApiUrl`, then the spec's\r\n first `servers[].url`.\r\n\r\nProps: `specConfiguration` (see `SpecConfiguration`) and `children`.\n\n**Example:**\n\n```tsx\r\n\r\n \r\n\r\n```" }, "CurrencyField": { "name": "CurrencyField", "kind": "component", "path": "react-openapi.CurrencyField", "signature": "CurrencyField(__namedParameters: CurrencyFieldProps): React.JSX.Element", "docstring": "Display a monetary amount as tabular-numeral text, colored red when negative\r\nand green otherwise.\r\n\r\nProps:\r\n- `value` - the amount to display.\r\n- `currency` - ISO code (see `formatCurrency`); defaults to INR.\r\n- `large` - use a slightly larger font (for detail views)." }, "DetailFieldRenderer": { "name": "DetailFieldRenderer", "kind": "component", "path": "react-openapi.DetailFieldRenderer", "signature": "DetailFieldRenderer(__namedParameters: DetailFieldProps): null | React.JSX.Element", "docstring": "Render a labeled field in the detail view.\r\n\r\nFields hidden in detail render nothing. Currency values use `CurrencyField`\r\n(large), images render as a rounded avatar with the resolved media URL, and\r\nall other types delegate to `ListCellRenderer`.\r\n\r\nProps:\r\n- `field` - the field metadata to render.\r\n- `value` - the raw field value.\r\n- `displayFormat` - optional `{prop}` template for object values.\r\n- `basePath` - admin base path used to build FK navigation links." }, "extractFields": { "name": "extractFields", "kind": "function", "path": "react-openapi.extractFields", "signature": "extractFields(schemaName: string, schema: any, schemas: Record): FieldConfig[]", "docstring": "Convert an OpenAPI schema's properties into `FieldConfig` objects.\r\n\r\nReads the react-openapi spec extensions (`x-label`, `x-description`,\r\n`x-order`, `x-hidden`, `x-filterable`, `x-sortable`, `x-ui-type`,\r\n`x-upload-url`, `x-upload`, `x-autocomplete`, `x-fk`, `x-edit-as`) and\r\nresolves `$ref`/array-of-`$ref`/`oneOf` properties into inline-ref metadata\r\n(`refSchema`, `inlineDisplayFormat`) or, for discriminated unions,\r\n`oneOfOptions` + `discriminatorProperty`. Enum values are lifted from array\r\nitems so arrays-of-enum render as multi-selects. Plain filterable strings\r\ndefault to the `\"text\"` autocomplete (with a warning); an `x-autocomplete`\r\non a non-filterable field records a validation error.\n\n**Parameters:**\n\n- `schemaName` — Schema name (used in diagnostics).\n- `schema` — The schema object whose `properties` are read.\n- `schemas` — The spec's `components.schemas` (for `$ref` resolution).\n\n**Returns:**\n\nThe resolved fields, in `properties` order." }, "FkMultiSelectField": { "name": "FkMultiSelectField", "kind": "component", "path": "react-openapi.FkMultiSelectField", "signature": "FkMultiSelectField(__namedParameters: Props): React.JSX.Element", "docstring": "Multi-select input for array foreign-key (`x-fk`) fields.\r\n\r\nBacked by an MUI `Autocomplete` over `fkOptions`; selected values are matched\r\nagainst the option list and emitted as an array of option values. On open it\r\ncalls `onOpen` (for lazy FK loading) and freezes the current selection so\r\nalready-picked options sort first. Only one chip is shown inline (plus a\r\n`+N` chip) to keep the row compact; `loading` reflects `fkLoading`.\r\n\r\nProps:\r\n- `field` - the field metadata (label, description, readOnly).\r\n- `value` - the current array of selected FK values.\r\n- `onChange` - called with the new array of values.\r\n- `fkOptions` - available `{ value, label }` options.\r\n- `fkLoading` - whether options are still loading.\r\n- `onOpen` - invoked when the dropdown opens (triggers lazy load)." }, "formatCurrency": { "name": "formatCurrency", "kind": "function", "path": "react-openapi.formatCurrency", "signature": "formatCurrency(amount: number, currency?: string): string", "docstring": "Format an amount as a currency string using the `en-IN` locale.\r\n\r\nFalls back to `INR` when `currency` is missing or unsupported. Only the\r\nmagnitude is formatted (the sign is handled by the caller). Formatters are\r\ncached per currency code.\n\n**Parameters:**\n\n- `amount` — The numeric amount (sign is ignored).\n- `currency` — ISO code; one of INR/USD/EUR/GBP/AED/SGD, else INR.\n\n**Returns:**\n\nThe formatted currency string, e.g. `₹1,234.50`." }, "formatDate": { "name": "formatDate", "kind": "function", "path": "react-openapi.formatDate", "signature": "formatDate(value: any): string", "docstring": "\"2026-08-24\" -> \"24 Aug 2026\"; non-ISO values pass through." }, "formatDateTime": { "name": "formatDateTime", "kind": "function", "path": "react-openapi.formatDateTime", "signature": "formatDateTime(value: any): string", "docstring": "\"2026-08-24T09:07:25\" -> \"24 Aug 2026, 09:07\"; non-ISO values pass through." }, "FormFieldRenderer": { "name": "FormFieldRenderer", "kind": "component", "path": "react-openapi.FormFieldRenderer", "signature": "FormFieldRenderer(__namedParameters: FormFieldProps): null | React.JSX.Element", "docstring": "Choose and render the correct input control for a form field.\r\n\r\nDispatch order: upload -> `FileUploadField`; read-only (non-image) -> text;\r\nimage -> `ImageField`; FK array -> `FkMultiSelectField`; FK single ->\r\n`FkSelectField`; enum array -> `MultiEnumField`; enum -> select; boolean ->\r\ntoggle; currency/number/integer -> numeric input; date/date-time ->\r\n`DateField`; discriminated union -> `DiscriminatorField`; inline ref ->\r\n`JsonField`; otherwise a plain text field. Fields hidden in the form render\r\nnothing.\r\n\r\nProps:\r\n- `field` - the field metadata to render.\r\n- `value` - the current form value.\r\n- `onChange` - called with the new value.\r\n- `error` - validation error to display, if any.\r\n- `fkOptions`, `fkLoading`, `onFkOpen` - FK select options, loading state and\r\n lazy loader (for `x-fk` fields).\r\n- `recordId` - record id used by image upload fields." }, "getApi": { "name": "getApi", "kind": "function", "path": "react-openapi.getApi", "signature": "getApi(): AxiosInstance", "docstring": "Get the shared axios client initialized by `AppProvider` / `initApi`.\r\n\r\nUse this anywhere you need to talk to the API (the CRUD helpers in\r\n`useResource` already do). Prefer it over a fresh axios instance so the base\r\nURL, auth header and `401` handling are consistent.\n\n**Returns:**\n\nThe shared `AxiosInstance`.\n\n**Throws:**\n\nIf the client has not been initialized (i.e. `AppProvider` has not\r\nmounted with a valid `baseApiUrl`/`servers[].url`).\n\n**Example:**\n\n```ts\r\nconst rows = await getApi().get(\"/expenses\");\r\n```" }, "ListCellRenderer": { "name": "ListCellRenderer", "kind": "component", "path": "react-openapi.ListCellRenderer", "signature": "ListCellRenderer(__namedParameters: ListCellProps): React.JSX.Element", "docstring": "Render one field value inside a list table cell.\r\n\r\nHandles every `FieldConfig` shape: `—` for `null`/`undefined`, inline\r\n(non-FK) objects via `InlineRefField`, clickable FK chips that navigate to\r\nthe referenced record, chip lists for FK arrays, enum chips, image avatars\r\nwith resolved media URLs, boolean Yes/No chips, currency via `CurrencyField`,\r\nand date/date-time formatting. Arrays of inline refs render chips that open a\r\ndialog listing the item's fields.\r\n\r\nProps:\r\n- `field` - the field metadata to render.\r\n- `value` - the raw cell value.\r\n- `displayFormat` - optional `{prop}` template for object values.\r\n- `basePath` - admin base path used to build FK navigation links." }, "MultiEnumField": { "name": "MultiEnumField", "kind": "component", "path": "react-openapi.MultiEnumField", "signature": "MultiEnumField(__namedParameters: Props): React.JSX.Element", "docstring": "Multi-select input for array enums (`type: array` of `enum`), backed by an\r\nMUI `Autocomplete`. Selects from `field.enumValues`, shows the current\r\nselection as chips, and is disabled when the field is read-only.\r\n\r\nProps:\r\n- `field` - the field metadata (label, description, `enumValues`, readOnly).\r\n- `value` - the current array value.\r\n- `onChange` - called with the new array of selected values.\r\n- `error` - validation error to display, if any." }, "ProfileRoutes": { "name": "ProfileRoutes", "kind": "component", "path": "react-openapi.ProfileRoutes", "signature": "ProfileRoutes(): null | React.JSX.Element", "docstring": "Render the current user's profile screen.\r\n\r\nResolves the profile operation from the spec and renders the configured\r\n`profileComponents.view` or `profileComponents.edit` component, wrapping it\r\nwith data fetching and submit handling. Only `/profile/me` and\r\n`/profile/me/edit` are valid; any other `/:username` redirects to `/me`.\r\nThe view operation is a `GET`; edit uses `PUT`/`PATCH`.\r\n\r\nNotes:\r\n- Renders nothing when no matching operation or component is configured.\r\n- Must be inside an `AppProvider` and a router.\n\n**Example:**\n\n```tsx\r\n} />\r\n```" }, "sanitizePayload": { "name": "sanitizePayload", "kind": "function", "path": "react-openapi.sanitizePayload", "signature": "sanitizePayload(data: any, fields: FieldConfig[], schemas: Record, resolveFk?: FkResolver): Promise", "docstring": "Normalize a form payload into the shape the API expects.\r\n\r\nRecursively walks `data` against `fields` and:\r\n- resolves FK fields without an `x-fk.value` (id -> object), mapping `null`/\r\n `\"\"` to `null` (or resolving each element for FK arrays);\r\n- recurses into inline (`refSchema`) objects using the referenced schema's\r\n fields, mapping empty values to `{}` or `[]`;\r\n- maps empty array fields to `[]` and empty object fields to `{}`.\r\n\r\nFields not present in `fields` are copied through untouched.\n\n**Parameters:**\n\n- `data` — The raw form value (object or array).\n- `fields` — Field metadata for the current level.\n- `schemas` — The spec's `components.schemas` (for inline-ref recursion).\n- `resolveFk` — Resolves FK values to objects (defaults to identity).\n\n**Returns:**\n\nA new, normalized payload.\n\n**Example:**\n\n```ts\r\nconst body = await sanitizePayload(form, resource.fields, schemas, resolveFk);\r\n```" }, "SseConnectionStatus": { "name": "SseConnectionStatus", "kind": "component", "path": "react-openapi.SseConnectionStatus", "signature": "SseConnectionStatus(__namedParameters: SseConnectionStatusProps): React.JSX.Element", "docstring": "Small \"Connected\"/\"Disconnected\" pill bound to a resource's SSE state.\r\n\r\nProps:\r\n- `resourceName` - the resource whose connection state to display." }, "SseStreamView": { "name": "SseStreamView", "kind": "component", "path": "react-openapi.SseStreamView", "signature": "SseStreamView(__namedParameters: SseStreamViewProps): React.JSX.Element", "docstring": "Live view of an `x-sse` streaming resource.\r\n\r\nSubscribes to the resource's event stream (via `useResource().stream`),\r\nstamps each event with `_received_at`/`_seq`, appends it to the shared SSE\r\ncache, and shows a snackbar with the formatted event. Renders the connection\r\nstatus, a running event count, and the latest event's formatted text;\r\nshows \"Waiting for events…\" until the first event arrives. Cached events\r\nare restored on mount; the connection flag is reset on unmount.\r\n\r\nProps:\r\n- `resource` - the `ResourceConfig` to stream (must be `streaming`).\r\n- `pathParams` - values to substitute into `{param}` path templates." }, "useAppContext": { "name": "useAppContext", "kind": "hook", "path": "react-openapi.useAppContext", "signature": "useAppContext(): AppContextValue", "docstring": "Read the app context.\n\n**Returns:**\n\nThe loaded spec state: `config`, `resources`, `profileOperations`,\r\n`profileComponents`, `authConfig`, `schemas`, `loading`, `errors` and\r\n`warnings`.\n\n**Throws:**\n\nIf called outside of an `AppProvider`.\n\n**Example:**\n\n```tsx\r\nconst { resources, loading, errors } = useAppContext();\r\n```" }, "useFkFieldOptions": { "name": "useFkFieldOptions", "kind": "hook", "path": "react-openapi.useFkFieldOptions", "signature": "useFkFieldOptions(fields: FieldConfig[]): { fkLoading: Record; fkOptions: Record; loadFkOnOpen: void }", "docstring": "Loads select options for foreign-key (`x-fk`) fields in a field set.\r\n\r\nOption values bind to the target's `x-fk.value` property when set (e.g.\r\naccount names), otherwise to the target resource's primary key. Fields with\r\n`fk.prefetch === true` load immediately; others load on demand through the\r\nreturned `loadFkOnOpen`. Options are cached per field name.\r\n\r\nNotes:\r\n- For a paginated target it requests `?limit=0` and expects `{ items }`;\r\n for a non-paginated target it expects a bare array.\r\n- Invalid responses and request errors are swallowed, leaving the field\r\n without suggestions.\n\n**Parameters:**\n\n- `fields` — The field set to scan for `x-fk` relationships.\n\n**Returns:**\n\n`fkOptions` (per field name), `fkLoading` (per field name) and\r\n`loadFkOnOpen(fieldName)`.\n\n**Example:**\n\n```tsx\r\nconst { fkOptions, fkLoading, loadFkOnOpen } = useFkFieldOptions(resource.fields);\r\n```" }, "useItemSse": { "name": "useItemSse", "kind": "hook", "path": "react-openapi.useItemSse", "signature": "useItemSse(url: null | string, handlers: ItemSseHandlers): ItemSseResult", "docstring": "Subscribe to a Server-Sent Events (SSE) stream for a single item.\r\n\r\nOpens an `EventSource` for `url` (resolved against the shared API base URL)\r\nand pushes each parsed JSON message onto `events`. Connection state is\r\nexposed via `connected`. Pass `null` to disable the subscription; the socket\r\nis closed and `connected` reset on unmount or when `url` changes. Malformed\r\nJSON payloads are ignored.\n\n**Parameters:**\n\n- `url` — Absolute-from-base path of the stream, or `null` to disable.\n- `handlers` — `onEvent` (per message), plus optional `onOpen`/`onError`.\n\n**Returns:**\n\n`{ connected, events }` for the active subscription.\n\n**Example:**\n\n```tsx\r\nconst { connected, events } = useItemSse(`/tasks/${id}/events`, {\r\n onEvent: (e) => console.log(e),\r\n});\r\n```" }, "useResource": { "name": "useResource", "kind": "hook", "path": "react-openapi.useResource", "signature": "useResource(resourceName: string): UseResourceReturn", "docstring": "Resource-scoped CRUD helpers and filter-widget factory for one resource.\r\n\r\nResolves the resource by name from the app context and returns:\r\n- `resource` - the resolved `ResourceConfig` (or `null` until loaded).\r\n- `components` - a map of field name -> filter component. The widget is\r\n chosen by field shape (boolean, FK, enum, number, date, inline-ref, or, via\r\n `field.autocomplete`, text/token/email/phone). In `client` filter mode\r\n option suggestions derive from `data`; in `server` mode FK/ref options are\r\n fetched (FK options are cached globally per target resource).\r\n- `list`, `get`, `create`, `update`, `remove` - CRUD via the shared axios\r\n client. `create`/`update` run `sanitizePayload` (resolving FK ids to\r\n objects). `patch` is present only when the spec exposes a PATCH operation.\r\n- `stream` - subscribe to an `x-sse` stream via `EventSource`, resolving\r\n `{pathParams}`; present only for streaming resources.\r\n- `loading` / `error` - request state (`error` parsed from the response\r\n body: an array of `{msg}` errors, a `detail` string, or `message`).\r\n\r\nNotes:\r\n- `list`/`get` accept both a bare array and `{ total, items }`; paginated\r\n resources require the latter.\r\n- Methods throw (and set `error`) when the resource is not loaded yet.\n\n**Parameters:**\n\n- `resourceName` — The resource name (URL path segment) to bind to.\n\n**Returns:**\n\nThe bound resource, CRUD methods, filter `components`, streaming\r\nsubscription and request state.\n\n**Example:**\n\n```tsx\r\nconst { resource, list, create } = useResource(\"expenses\");\r\n```" } } } }