Turn openapi specifications into react building blocks.
Create a new stencil buildStencil(openapiDoc, options)
openapiDocObject: The OpenAPI document that defines the api.optionsObject: An object containing various configuration options.serverObject: Configuration related to the server.urlString: The URL of the server.
devModeBoolean: When devMode is on, some additional information may be shown when an error occurs. For example if you try to access a field that does not exist it will render a warning component that shows the error. When devMode is false this will be hidden.useTokenFunction: A function that returns the auth token.componentsObject: Some generic components that may be reused in different places.loadingArray: An array of loading components.nameString: The name of the loading component.componentFunction: A function that returns a React component for loading.
useFormObject: Configuration for form fields, buttons, errors, and forms.errorHandlerFunction: A function to handle form errors.fieldsArray of ComponentDefinition: An array of field component definitions.buttonsArray of ComponentDefinition: An array of component definitions.formErrorsArray of ComponentDefinition: An array of component definitions.formsArray of ComponentDefinition: An array of component definitions.
useListObject: Configuration for listsdefaultPageSizePositive Integer: How many results to show per page by default.emptyStates[ComponentDefinition]: Components to use for list empty states.loaders[ComponentDefinition]: Components to use for loading states.loadingErrors[ComponentDefinition]: Components to use for when loading fails.paginations[ComponentDefinition]: Components to use for pagination. The component will be provided with the following props:useQuerysetQueryParamuseQueryCountuseQueryParamcalculateNewQuery
Defines a component that can be used for some given task. For example a component in useForm.fields is expected to be a form field that will update form data in some way. Stencil is designed to allow for many different versions of components for the same task. For example, you might want to have form fields for different themes. Or you might have many different form fields that can handle text, (eg. a text area, a text input, and a growing text area). You can easily make one of these be the default, while still having the others available in building your form.
nameString: The name of the component.predicateFunction: A function to determine if the component can be used. This is only applicable to some types of component definitions, namely fields. You will be given the name and details about the field, and can return whether this component can handle the type of field. For example, if the type is boolean, you would return false for a text input component.themeString: The theme name of the field.priorityNumber: The priority of the field. The higher the number, the higher priority it is given. When resolving which field to use as the default, the one with the matching theme and highest priority will be chosen. (This filed will be included in theFieldsobject, and will be used if you let the form render fields itself instead of passing in children. eg.<Form />componentFunction: A function that returns a React component for the field. eg.() => props => <input {...props}/>. For field components, you will normally want to useuseFormContextfrom react hook form to hook the component up to the form state.
Stencil is the object that is returned by buildStencil. It has a number of useful utilities.
queriesObject where all keys are generatedQueryHooks: All of the generated react-query hooks for thegetresources. Eg. for apublic/postsendpoint there will be astencil.queries.usePublicPostshook.
TODO: add documentation about stencil.queries
nameString: The name of the url (you can see all available names instencil.urls)methodString: The http method of the form (eg.post,patch,delete)optionsuseFormOptions:
themeString: Which theme to use, defaults todefaultuseFormOptionsreactHookFormUseFormOptions: The object that will get passed to react-hook-form'suseForm, this is where you can pass along a resolver for validation, or manually pass defaultValues.
nameString: The name of the url (you can see all available names instencil.urls)optionsuseListOptions:
additionalFiltersFilter: Add filters that are not included in the open api document.idString: This is used to namespace query param args. Eg. if id isfoothen a query param would look like?foo.bar=1&foo.baz=2useQueryHookloaderString: The name of the loader to use.emptyStateString: The name of the emptyState to use.defaultQueriesObject: The default queries to use.
This is an object that looks the same as an openapi query param, for example:
{ name: 'is_notable', value: 'true', schema: { type: 'string' } }