Skip to content

Commit

Permalink
Merge pull request #1 from mingoes/master
Browse files Browse the repository at this point in the history
Fixed bug where schema.type would not be recognised
  • Loading branch information
Manweill committed Aug 27, 2018
2 parents f8d99da + 2964ff0 commit 1dcfe07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/baseInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface IParameter {
export interface IParameterSchema {
$ref: string
items?: IParameterItems
type: string
}


Expand Down
10 changes: 9 additions & 1 deletion src/requestCodeGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ function getRequestParameters(params: IParameter[]) {
let propType = ''
// 引用类型定义
if (p.schema) {
propType = p.schema.items ? refClassName(p.schema.items.$ref) : refClassName(p.schema.$ref)
if (p.schema.items) {
propType = refClassName(p.schema.items.$ref)
} else if (p.schema.$ref) {
propType = refClassName(p.schema.$ref)
} else if (p.schema.type) {
propType = p.schema.type
} else {
throw new Error('Could not find property type on schema')
}
} else if (p.items) {
propType = p.items.$ref ? refClassName(p.items.$ref) + '[]' : toBaseType(p.items.type) + '[]'
}
Expand Down

0 comments on commit 1dcfe07

Please sign in to comment.