Function createOpenApiSpec

  • Given an Api metadata definition, this generates anOpenApi specification JSON blob, which then can be used by a variety of tooling. For estuary-rpc projects, getting documentation through one of these projects is quite straightforward

    • swagger-ui is a clientside npm package for rendering OpenAPI documentation to a browser DOM object,
    • swagger-ui-react is a clientside npmpackage for rendering OpenAPI documentation to a React component, and
    • swagger-ui-dist is a serverseide npm package for rendering OpenAPI documentation to compiled static HTML

    Returns

    A

    Example

    function MySpec({api}: {api: MyApiTypeOf<unknown, MyMetaType>} ) {
    const spec = createOpenApiSpec(exampleApiMeta, {
    info: {
    title: "Example API",
    version: "foo.bar",
    },
    });
    return <SwaggerUI spec={spec} />;
    }

    Type Parameters

    • Meta extends SimpleMeta

      The Meta type used by your Api metadata definition (SimpleMeta is sufficient)

    Parameters

    • api: Api<unknown, Meta>

      Your Api metadata definition

    • Optional additionalSwag: any

      extend the generated api spec however you want, so that the output of this function is a valid spec. Should probably at least provide {info: {title: "Your Title", version: "1.0.0"}}

    • Optional endpointMapping: ((currentSwaggerJson: Record<string, unknown>, currentMeta: Meta) => Record<string, unknown>)

      method to postprocess the OpenAPI object representing a specific endopint given its current metadata, useful for reacting to custom Metadata used in your project

        • (currentSwaggerJson: Record<string, unknown>, currentMeta: Meta): Record<string, unknown>
        • Parameters

          • currentSwaggerJson: Record<string, unknown>
          • currentMeta: Meta

          Returns Record<string, unknown>

    Returns any

Generated using TypeDoc