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

🐛 [BUG] umijs openapi 处理对象继承时无法生成扩展属性 #10840

Closed
ianhash opened this issue Jul 13, 2023 · 0 comments · Fixed by chenshuai2144/openapi2typescript#112

Comments

@ianhash
Copy link

ianhash commented Jul 13, 2023

🐛 bug 描述

如题,复现步骤和期望结果见下方描述。我初步怀疑是 @umijs/openapi 在处理继承时没有考虑合并properties声明的属性。

resolveAllOfObject(schemaObject: SchemaObject) {
    const props = (schemaObject.allOf || []).map((item) =>
      item.$ref ? [{ ...item, type: getType(item).split('/').pop() }] : this.getProps(item),
    );
    return { props };
  }

📷 复现步骤 | Recurrence steps

swagger api 定义:

definitions:
  Response:
    type: object
    properties:
      code:
        type: string
      status:
        type: integer
      message:
        type: string
    discriminator: data
  BoolResponse:
    allOf:
      - $ref: '#/definitions/Response'
    type: object
    required:
      - data
    properties:
      data:
        type: boolean

通过 yarn openapi 生成的的最终结果:

type Response = {
    code?: string;
    message?: string;
    status?: number;
  };

  type BoolResponse =
    // #/components/schemas/Response
    Response;

🏞 期望结果 | Expected results

type Response = {
    code?: string;
    message?: string;
    status?: number;
  };

  type BoolResponse =
    // #/components/schemas/Response
    Response & {data: boolean};

© 版本信息

package.json:

 "dependencies": {
    "@ant-design/icons": "^4.7.0",
    "@ant-design/pro-components": "^2.3.37",
    "@ant-design/use-emotion-css": "1.0.4",
    "@umijs/plugin-openapi": "^1.3.3",
    "@umijs/route-utils": "^2.1.3",
    "antd": "^5.0.0",
    "classnames": "^2.3.2",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "omit.js": "^2.0.2",
    "rc-menu": "^9.6.4",
    "rc-util": "^5.24.4",
    "react": "^18.0.0",
    "react-dev-inspector": "^1.8.1",
    "react-dom": "^18.0.0",
    "react-helmet-async": "^1.3.0"
  },

🚑 其他信息

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 a pull request may close this issue.

1 participant