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

OpenAPI Types package, Path Item Object #879

Open
dbwodlf3 opened this issue Jul 5, 2023 · 1 comment
Open

OpenAPI Types package, Path Item Object #879

dbwodlf3 opened this issue Jul 5, 2023 · 1 comment

Comments

@dbwodlf3
Copy link

dbwodlf3 commented Jul 5, 2023

https://github.com/kogosoftwarellc/open-api/tree/main/packages/openapi-types#readme

export type PathItemObject = OpenAPIV3_1.PathItemObject<OperationObject>;

export const PathItemObject: PathItemObject = {
  // $ref: null,
  summary: "",
  description: "",
  servers: [],
  parameters: [],
  $ref: "",
};

export type OperationObject =
  OpenAPIV3_1.OperationObject<OpenAPIV3.OperationObject>;

export const OperationObject: OperationObject = {
  tags: [],
  summary: "",
  description: "",
  externalDocs: {
    url: "",
  },
  operationId: "",
  parameters: [],
  requestBody: {
    content: {
      "application/json": {
        schema: {
          type: "object",
          properties: {},
        },
      },
    },
  },
  responses: {
    "200": {
      description: "Success",
      content: {},
    },
  },
  callbacks: {},
  deprecated: false,
  security: [],
  servers: [],
};

export type OperationObject2 =
  OpenAPIV3_1.OperationObject;

export const OperationObject: OperationObject2 = {
  tags: [],
  summary: "",
  description: "",
  externalDocs: {
    url: "",
  },
  operationId: "",
  parameters: [],
  requestBody: {
    content: {
      "application/json": {
        schema: {
          type: "object",
          properties: {},
        },
      },
    },
  },
  responses: {
    "200": {
      description: "Success",
      content: {},
    },
  },
  callbacks: {},
  deprecated: false,
  security: [],
  servers: [],
};
// it works.
PathItemObject.get = OperationObject;

// it doesn't work.
PathItemObject.post = OperationObject2;

package version is "openapi-types": "^12.1.3",

@dbwodlf3
Copy link
Author

dbwodlf3 commented Jul 5, 2023

OpenAPI 3_1 is reusing OpenAPI3 type definition, but some cases it doesn't work well.

requestBody?: ((OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject) & 
                          (OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.RequestBodyObject))

if requestBody is OpenAPIV3_1, it doesn't work. it works only when OpenAPIV3.RequestBodyObject

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

No branches or pull requests

1 participant