Skip to content

must have required property 'requestBody' #860

Open

Description

@ilomon10

i tried to use openapi-backend with express with this setup:

(req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
   api.handleRequest(
      {
        method: req.method,
        path: req.path,
        query: req.query,
        body: req.body,
        headers: req.headers,
        params: req.params,
      },
      req,
      res,
    );
}

with this schema:

import { Document } from "openapi-backend";

export const apiSchema: Document = {
  openapi: "3.0.1",
  info: {
    title: "REST API",
    version: "1",
  },
  servers: [
    {
      url: "/api/v1",
      description: "API Version 1",
    },
    {
      url: "/api/v2",
      description: "API Version 2",
    },
  ],
  paths: {
    "/attendance/subscribe": {
      post: {
        operationId: "postSubscribeAttendance",
        summary: "Subscribe to attendance",
        requestBody: {
          content: {
            "application/json": {
              schema: {
                type: "object",
                required: ["callbackUrl"],
                properties: {
                  callbackUrl: {
                    type: "string",
                    // format: "url",
                    example: "http://yourserver.com/send/callback/here",
                  },
                },
              },
            },
          },
        },
        responses: {
          "200": {
            description: "ok",
            content: {
              "text/plain": {
                schema: {
                  type: "string",
                },
              },
            },
          },
        },
      },
    },
  },
};

but no luck

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions