openapi-typescript
openapi-typescript copied to clipboard
🚧 openapi-decorators and openapi-adonis
Introduction
This Pull request brings two new libraries:
openapi-decorators
A utility library to automatically generate OpenAPI schemas by leveraging Typescript decorators and metadata.
openapi-adonis
A library to generate OpenAPI schemas for Adonis.js framework by using openapi-decorators
⚠ This Pull request is a work in progress and is subject to changes.
import { apiOperation, apiResponse } from "openapi-adonis/decorators";
import User from "#models/user";
class UsersController {
@apiOperation({ summary: "List users" })
@apiResponse({ type: [User] })
async list() {
return User.findManyBy({});
}
}
import { apiProperty } from "openapi-adonis/decorators";
class User {
@apiProperty()
declare id: number;
@apiProperty()
declare name: string;
@apiProperty({ required: false })
declare mobile?: string;
}
import router from "@adonisjs/core/services/router";
import AdonisOpenAPI from "openapi-adonis";
const UsersController = () => import("#controllers/users_controller");
router.post("/users", [UsersController, "create"]);
const builder = AdonisOpenAPI.document().setTitle("OpenAPI Adonis Example");
AdonisOpenAPI.setup("/docs", router, builder);
⚠️ No Changeset found
Latest commit: e5b4a619091c3585096c21e79dfd1ff49bdc7cac
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
👀
@kerwanp can you please give us an update? is there another PR being prepared for adonis or is this abandoned?
@kerwanp can you please give us an update? is there another PR being prepared for adonis or is this abandoned?
There is an other PR under the way! A complete rewrite, much cleaner one! https://github.com/openapi-ts/openapi-typescript/pull/1992
The first release of the Adonis integration should be available this weekend. You can join the Adonis discord to get updated.