Skip to content

🚧 openapi-decorators and openapi-adonis #1834

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

Closed
wants to merge 11 commits into from

Conversation

kerwanp
Copy link
Contributor

@kerwanp kerwanp commented Aug 9, 2024

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);

Copy link

changeset-bot bot commented Aug 9, 2024

⚠️ No Changeset found

Latest commit: e5b4a61

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

@iffa
Copy link

iffa commented Aug 15, 2024

👀

@kerwanp kerwanp closed this Nov 6, 2024
@zecar
Copy link

zecar commented Nov 7, 2024

@kerwanp can you please give us an update? is there another PR being prepared for adonis or is this abandoned?

@kerwanp
Copy link
Contributor Author

kerwanp commented Nov 9, 2024

@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! #1992

The first release of the Adonis integration should be available this weekend. You can join the Adonis discord to get updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants