mirror of
https://github.com/tribufu/proxmox-ve-openapi
synced 2026-05-06 07:07:28 +00:00
Fixed a few more problems with the generator
This commit is contained in:
parent
1635f27234
commit
f32f60d772
2 changed files with 370 additions and 333 deletions
|
|
@ -9,7 +9,7 @@ const tags = []
|
|||
const capitalizeFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
||||
|
||||
function generateOpId(method, path){
|
||||
let operation = path.split("/").map(capitalizeFirst).join('')
|
||||
let operation = path.split("/").map(capitalizeFirst).join('').replace(/[\-\_]/g, '')
|
||||
|
||||
operation = operation.replace(/\{[a-z]*\}/g, 'Single')
|
||||
|
||||
|
|
@ -39,7 +39,17 @@ function buildResponseSchema(source){
|
|||
schema.items = buildResponseSchema(source.items)
|
||||
if(source.type === 'object' && source.properties){
|
||||
schema.properties = {}
|
||||
Object.keys(source.properties || {}).forEach(k => schema.properties[k] = buildResponseSchema(source.properties[k]))
|
||||
Object.keys(source.properties || {}).forEach(k => {
|
||||
if(k.endsWith('[n]')){
|
||||
const nk = k.substr(0, k.length-3)
|
||||
schema.properties[nk] = {
|
||||
type: 'array',
|
||||
items: buildResponseSchema(source.properties[k])
|
||||
}
|
||||
}else{
|
||||
schema.properties[k] = buildResponseSchema(source.properties[k])
|
||||
}
|
||||
})
|
||||
}
|
||||
return schema
|
||||
}
|
||||
|
|
@ -49,6 +59,17 @@ function parseInfo(path, method, info){
|
|||
id = mapping[id] || id
|
||||
const properties = (info.parameters && info.parameters.properties) ? Object.keys(info.parameters.properties).map(k => ({ name: k, ...info.parameters.properties[k] })) : []
|
||||
|
||||
properties.map(p => {
|
||||
if(p.type === 'string' && p.name.endsWith('[n]')){
|
||||
p.name = p.name.substr(0, p.name.length-3);
|
||||
p.type = 'array';
|
||||
p.items = {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
return p;
|
||||
});
|
||||
|
||||
const requestName = capitalizeFirst(id) + 'Request'
|
||||
const responseName = capitalizeFirst(id) + 'Response'
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue