openapi3-ts icon indicating copy to clipboard operation
openapi3-ts copied to clipboard

Documentation

Open alichampion opened this issue 2 years ago • 5 comments

Very Poor documentation!

No example of how to use it.

@pjmolina please at least attach an example.

After searching a lot I got this code sandbox example.

https://codesandbox.io/s/olpj88zyly?file=/src/index.ts

alichampion avatar Mar 22 '22 07:03 alichampion

You can build schema. Example:

import { OpenApiBuilder, PathsObject, PathItemObject, ResponseObject } from "openapi3-ts";
import apiConfig from "./config";

const getUserResponse: ResponseObject = {
    description: "Gets user info by user id.",
}

const user: PathItemObject = {
    get: {
        operationId: "user",
        responses: {
            "200": getUserResponse,
        }
    }
}

const paths: PathsObject = {
    "/user": user,
}

const builder = OpenApiBuilder.create({
    openapi: apiConfig.openAPIVersion,
    info: {
        title: apiConfig.title,
        version: apiConfig.version,
        description: apiConfig.description,
        contact: apiConfig.contact,
    },
    paths,
    servers: [
        {
            url: `${apiConfig.host}:${apiConfig.port}`,
        },
    ],
});

builder.addPath("/articles", {
    get: {
        operationId: "articles",
        responses: {
            "200": {
                description: "Gets all articles.",
            },
        },
        parameters: [
            {
                name: "page",
                in: "query",
            },
        ],
    },
});

export const definition = builder.getSpec(); // js object
export const definitionJson = builder.getSpecAsJson(); // json
export const definitionYaml = builder.getSpecAsYaml(); // yaml

svrakata avatar May 02 '22 16:05 svrakata

Very Poor documentation!

No example of how to use it.

I mean yea.

Kinda surprising that no-one has even tried to contribute documentation given that this project seems to have like 550k weekly installs

strazto avatar Jul 21 '22 07:07 strazto

Thanks for the time taken to prepare and example @svrakata (we can use it as the seed for minimal docs). As you all know, documentation like any other feature requires time. Unit tests provided are a good source for documentation. PR are open and therefore, contributions are welcome. Thank you in advance.

pjmolina avatar Aug 16 '22 15:08 pjmolina

The lack of documentation has now even made these comments out of date.

CaptainYarb avatar Oct 17 '23 17:10 CaptainYarb

https://codesandbox.io/s/olpj88zyly?file=/src/index.ts

So. someone who is trying to learn what all it can do and how to use it is responsible for creating documentation?

rddyck avatar Mar 28 '24 15:03 rddyck