Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add express-openapi types #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 17, 2024

  1. Add express-openapi types

    This commit includes typing all the public facing signatures. The types
    also include API documentation in JSDoc format that is available in the
    root README of the repository. Most of the types were deduced by hand
    from the source code and tested with actual runtime data to make sure
    that the written types match with the runtime data.
    
    The component methods use function overloading to provide better code
    completion of the expected parameters and return values. For example
    giving a type and a name to `component("examples", "FooExample")`
    returns the expected type of `ReferenceObject` conforming to the API
    documentation.
    
    Similarly setting the type for the component function affects what it
    will return or take as an input. The input parameter and return type
    will conform to the expected type. For example:
    
    ```ts
    const schemas = openapi.component("schemas");
    //    ^? { [key: string]: SchemaObject | ReferenceObject }
    
    const examples = openapi.component("examples");
    //    ^? { [key: string]: ExampleObject | ReferenceObject }
    ```
    
    The types utilize existing types defined in "openapi-types" and most of
    the public facing API functions rely on these types.
    
    The initial typings file was derived from the work presented here: wesleytodd#25 (comment)
    erikjuhani committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    7f6336d View commit details
    Browse the repository at this point in the history