Fixed another generator issue

This commit is contained in:
JanHolger 2020-12-22 07:11:42 +01:00
parent f32f60d772
commit a97a88e2c2
2 changed files with 110 additions and 9 deletions

View file

@ -31,6 +31,19 @@ function generateOpId(method, path){
const mapping = require('./mapping') const mapping = require('./mapping')
function filterSchema(p){
const schema = {
type: p.type
}
if(p.items)
schema.items = filterSchema(p.items)
if(p.properties){
schema.properties = {}
Object.keys(p.properties).forEach(name => schema.properties[name] = filterSchema(p.properties[name]))
}
return schema
}
function buildResponseSchema(source){ function buildResponseSchema(source){
const schema = { type: source.type || 'string', description: source.description || '' } const schema = { type: source.type || 'string', description: source.description || '' }
if(schema.type === 'null') if(schema.type === 'null')
@ -57,15 +70,13 @@ function buildResponseSchema(source){
function parseInfo(path, method, info){ function parseInfo(path, method, info){
let id = generateOpId(method, path); let id = generateOpId(method, path);
id = mapping[id] || id id = mapping[id] || id
const properties = (info.parameters && info.parameters.properties) ? Object.keys(info.parameters.properties).map(k => ({ name: k, ...info.parameters.properties[k] })) : [] let properties = (info.parameters && info.parameters.properties) ? Object.keys(info.parameters.properties).map(k => ({ name: k, ...info.parameters.properties[k] })) : []
properties.map(p => { properties = properties.map(p => {
if(p.type === 'string' && p.name.endsWith('[n]')){ if(p.type === 'string' && p.name.endsWith('[n]')){
p.name = p.name.substr(0, p.name.length-3); p.items = JSON.parse(JSON.stringify(p))
p.type = 'array'; p.type = 'array';
p.items = { p.name = p.name.substr(0, p.name.length-3);
type: 'string'
}
} }
return p; return p;
}); });
@ -108,9 +119,7 @@ function parseInfo(path, method, info){
required: [] required: []
} }
properties.filter(p => !path.includes('{'+p.name+'}')).forEach(p => { properties.filter(p => !path.includes('{'+p.name+'}')).forEach(p => {
models[requestName].properties[p.name] = { models[requestName].properties[p.name] = filterSchema(p)
type: p.type
}
if(p.optional !== 1){ if(p.optional !== 1){
models[requestName].required.push(p.name) models[requestName].required.push(p.name)
} }

View file

@ -10198,6 +10198,8 @@ components:
type: string type: string
link: link:
type: array type: array
items:
type: string
nodeid: nodeid:
type: integer type: integer
votes: votes:
@ -10214,6 +10216,8 @@ components:
type: boolean type: boolean
link: link:
type: array type: array
items:
type: string
new_node_ip: new_node_ip:
type: string type: string
nodeid: nodeid:
@ -10232,6 +10236,8 @@ components:
type: string type: string
link: link:
type: array type: array
items:
type: string
nodeid: nodeid:
type: integer type: integer
password: password:
@ -11030,14 +11036,20 @@ components:
type: string type: string
hostpci: hostpci:
type: array type: array
items:
type: string
hotplug: hotplug:
type: string type: string
hugepages: hugepages:
type: string type: string
ide: ide:
type: array type: array
items:
type: string
ipconfig: ipconfig:
type: array type: array
items:
type: string
ivshmem: ivshmem:
type: string type: string
keephugepages: keephugepages:
@ -11064,14 +11076,20 @@ components:
type: string type: string
net: net:
type: array type: array
items:
type: string
numa: numa:
type: array type: array
items:
type: string
onboot: onboot:
type: boolean type: boolean
ostype: ostype:
type: string type: string
parallel: parallel:
type: array type: array
items:
type: string
pool: pool:
type: string type: string
protection: protection:
@ -11082,14 +11100,20 @@ components:
type: string type: string
sata: sata:
type: array type: array
items:
type: string
scsi: scsi:
type: array type: array
items:
type: string
scsihw: scsihw:
type: string type: string
searchdomain: searchdomain:
type: string type: string
serial: serial:
type: array type: array
items:
type: string
shares: shares:
type: integer type: integer
smbios1: smbios1:
@ -11122,14 +11146,20 @@ components:
type: boolean type: boolean
unused: unused:
type: array type: array
items:
type: string
usb: usb:
type: array type: array
items:
type: string
vcpus: vcpus:
type: integer type: integer
vga: vga:
type: string type: string
virtio: virtio:
type: array type: array
items:
type: string
vmgenid: vmgenid:
type: string type: string
vmid: vmid:
@ -11440,14 +11470,20 @@ components:
type: string type: string
hostpci: hostpci:
type: array type: array
items:
type: string
hotplug: hotplug:
type: string type: string
hugepages: hugepages:
type: string type: string
ide: ide:
type: array type: array
items:
type: string
ipconfig: ipconfig:
type: array type: array
items:
type: string
ivshmem: ivshmem:
type: string type: string
keephugepages: keephugepages:
@ -11474,14 +11510,20 @@ components:
type: string type: string
net: net:
type: array type: array
items:
type: string
numa: numa:
type: array type: array
items:
type: string
onboot: onboot:
type: boolean type: boolean
ostype: ostype:
type: string type: string
parallel: parallel:
type: array type: array
items:
type: string
protection: protection:
type: boolean type: boolean
reboot: reboot:
@ -11492,14 +11534,20 @@ components:
type: string type: string
sata: sata:
type: array type: array
items:
type: string
scsi: scsi:
type: array type: array
items:
type: string
scsihw: scsihw:
type: string type: string
searchdomain: searchdomain:
type: string type: string
serial: serial:
type: array type: array
items:
type: string
shares: shares:
type: integer type: integer
skiplock: skiplock:
@ -11528,14 +11576,20 @@ components:
type: boolean type: boolean
unused: unused:
type: array type: array
items:
type: string
usb: usb:
type: array type: array
items:
type: string
vcpus: vcpus:
type: integer type: integer
vga: vga:
type: string type: string
virtio: virtio:
type: array type: array
items:
type: string
vmgenid: vmgenid:
type: string type: string
vmstatestorage: vmstatestorage:
@ -11600,14 +11654,20 @@ components:
type: string type: string
hostpci: hostpci:
type: array type: array
items:
type: string
hotplug: hotplug:
type: string type: string
hugepages: hugepages:
type: string type: string
ide: ide:
type: array type: array
items:
type: string
ipconfig: ipconfig:
type: array type: array
items:
type: string
ivshmem: ivshmem:
type: string type: string
keephugepages: keephugepages:
@ -11634,14 +11694,20 @@ components:
type: string type: string
net: net:
type: array type: array
items:
type: string
numa: numa:
type: array type: array
items:
type: string
onboot: onboot:
type: boolean type: boolean
ostype: ostype:
type: string type: string
parallel: parallel:
type: array type: array
items:
type: string
protection: protection:
type: boolean type: boolean
reboot: reboot:
@ -11652,14 +11718,20 @@ components:
type: string type: string
sata: sata:
type: array type: array
items:
type: string
scsi: scsi:
type: array type: array
items:
type: string
scsihw: scsihw:
type: string type: string
searchdomain: searchdomain:
type: string type: string
serial: serial:
type: array type: array
items:
type: string
shares: shares:
type: integer type: integer
skiplock: skiplock:
@ -11688,14 +11760,20 @@ components:
type: boolean type: boolean
unused: unused:
type: array type: array
items:
type: string
usb: usb:
type: array type: array
items:
type: string
vcpus: vcpus:
type: integer type: integer
vga: vga:
type: string type: string
virtio: virtio:
type: array type: array
items:
type: string
vmgenid: vmgenid:
type: string type: string
vmstatestorage: vmstatestorage:
@ -11974,10 +12052,14 @@ components:
type: integer type: integer
mp: mp:
type: array type: array
items:
type: string
nameserver: nameserver:
type: string type: string
net: net:
type: array type: array
items:
type: string
onboot: onboot:
type: boolean type: boolean
ostemplate: ostemplate:
@ -12020,6 +12102,8 @@ components:
type: boolean type: boolean
unused: unused:
type: array type: array
items:
type: string
vmid: vmid:
type: integer type: integer
required: required:
@ -12061,10 +12145,14 @@ components:
type: integer type: integer
mp: mp:
type: array type: array
items:
type: string
nameserver: nameserver:
type: string type: string
net: net:
type: array type: array
items:
type: string
onboot: onboot:
type: boolean type: boolean
ostype: ostype:
@ -12093,6 +12181,8 @@ components:
type: boolean type: boolean
unused: unused:
type: array type: array
items:
type: string
CreateNodesSingleLxcSingleStatusStartRequest: CreateNodesSingleLxcSingleStatusStartRequest:
title: CreateNodesSingleLxcSingleStatusStartRequest title: CreateNodesSingleLxcSingleStatusStartRequest
type: object type: object
@ -13031,6 +13121,8 @@ components:
type: string type: string
acmedomain: acmedomain:
type: array type: array
items:
type: string
delete: delete:
type: string type: string
description: description: