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

生成 open api 时,能自定义 Request 对象的名称,且能输出字段的 description #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vfasky
Copy link

@vfasky vfasky commented Dec 16, 2019

自定义 Request 对象的名称

在 validateMetaInfo 增加 schemaName 字段,用于解决 Requestobject 时, 名称总是 GenType_

@route('POST /api/body', {
    name: 'post with body: q',
    validateMetaInfo: [
      {
        name: 'q',
        rule: {
          schemaName: 'ReqData',
          type: 'object',
          rule: {
            a: {
              type: 'string'
            },
            b: {
              type: 'number'
            }
          }
        }
      }
    ]
  })
  post(q: { a: string, b: number }) {
    return 'ok';
  }

生成 open api 时,Request 属性输出 description

@route('/api/query', {
    name: 'get with query: q',
    validateMetaInfo: [
      {
        name: 'q',
        rule: {
          type: 'string',
          description: 'query'
        }
      }
    ]
  })
  getQuery(q: string) {
    return 'ok';
  }

@codecov-io
Copy link

codecov-io commented Dec 16, 2019

Codecov Report

Merging #17 into master will increase coverage by 1.47%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage   78.45%   79.92%   +1.47%     
==========================================
  Files          24       24              
  Lines         557      558       +1     
  Branches       71       73       +2     
==========================================
+ Hits          437      446       +9     
+ Misses         97       88       -9     
- Partials       23       24       +1
Impacted Files Coverage Δ
lib/openapi/index.ts 70.45% <0%> (+9.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb68643...04a0a34. Read the comment docs.

@zhang740
Copy link
Owner

validateMetaInfo 的数据是对齐 https://github.com/node-modules/parameter 这个库的,其实可以使用 OAS3 的定义来替代,用 schemas 那个属性,手写或者通过这个模块内的 ts 编译插件

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