OpenAPIv2.go 279 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729
  1. // Copyright 2017 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // THIS FILE IS AUTOMATICALLY GENERATED.
  15. package openapi_v2
  16. import (
  17. "fmt"
  18. "github.com/googleapis/gnostic/compiler"
  19. "gopkg.in/yaml.v2"
  20. "regexp"
  21. "strings"
  22. )
  23. // Version returns the package name (and OpenAPI version).
  24. func Version() string {
  25. return "openapi_v2"
  26. }
  27. // NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not.
  28. func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*AdditionalPropertiesItem, error) {
  29. errors := make([]error, 0)
  30. x := &AdditionalPropertiesItem{}
  31. matched := false
  32. // Schema schema = 1;
  33. {
  34. m, ok := compiler.UnpackMap(in)
  35. if ok {
  36. // errors might be ok here, they mean we just don't have the right subtype
  37. t, matchingError := NewSchema(m, compiler.NewContext("schema", context))
  38. if matchingError == nil {
  39. x.Oneof = &AdditionalPropertiesItem_Schema{Schema: t}
  40. matched = true
  41. } else {
  42. errors = append(errors, matchingError)
  43. }
  44. }
  45. }
  46. // bool boolean = 2;
  47. boolValue, ok := in.(bool)
  48. if ok {
  49. x.Oneof = &AdditionalPropertiesItem_Boolean{Boolean: boolValue}
  50. }
  51. if matched {
  52. // since the oneof matched one of its possibilities, discard any matching errors
  53. errors = make([]error, 0)
  54. }
  55. return x, compiler.NewErrorGroupOrNil(errors)
  56. }
  57. // NewAny creates an object of type Any if possible, returning an error if not.
  58. func NewAny(in interface{}, context *compiler.Context) (*Any, error) {
  59. errors := make([]error, 0)
  60. x := &Any{}
  61. bytes, _ := yaml.Marshal(in)
  62. x.Yaml = string(bytes)
  63. return x, compiler.NewErrorGroupOrNil(errors)
  64. }
  65. // NewApiKeySecurity creates an object of type ApiKeySecurity if possible, returning an error if not.
  66. func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecurity, error) {
  67. errors := make([]error, 0)
  68. x := &ApiKeySecurity{}
  69. m, ok := compiler.UnpackMap(in)
  70. if !ok {
  71. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  72. errors = append(errors, compiler.NewError(context, message))
  73. } else {
  74. requiredKeys := []string{"in", "name", "type"}
  75. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  76. if len(missingKeys) > 0 {
  77. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  78. errors = append(errors, compiler.NewError(context, message))
  79. }
  80. allowedKeys := []string{"description", "in", "name", "type"}
  81. allowedPatterns := []*regexp.Regexp{pattern0}
  82. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  83. if len(invalidKeys) > 0 {
  84. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  85. errors = append(errors, compiler.NewError(context, message))
  86. }
  87. // string type = 1;
  88. v1 := compiler.MapValueForKey(m, "type")
  89. if v1 != nil {
  90. x.Type, ok = v1.(string)
  91. if !ok {
  92. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  93. errors = append(errors, compiler.NewError(context, message))
  94. }
  95. // check for valid enum values
  96. // [apiKey]
  97. if ok && !compiler.StringArrayContainsValue([]string{"apiKey"}, x.Type) {
  98. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  99. errors = append(errors, compiler.NewError(context, message))
  100. }
  101. }
  102. // string name = 2;
  103. v2 := compiler.MapValueForKey(m, "name")
  104. if v2 != nil {
  105. x.Name, ok = v2.(string)
  106. if !ok {
  107. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2)
  108. errors = append(errors, compiler.NewError(context, message))
  109. }
  110. }
  111. // string in = 3;
  112. v3 := compiler.MapValueForKey(m, "in")
  113. if v3 != nil {
  114. x.In, ok = v3.(string)
  115. if !ok {
  116. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3)
  117. errors = append(errors, compiler.NewError(context, message))
  118. }
  119. // check for valid enum values
  120. // [header query]
  121. if ok && !compiler.StringArrayContainsValue([]string{"header", "query"}, x.In) {
  122. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3)
  123. errors = append(errors, compiler.NewError(context, message))
  124. }
  125. }
  126. // string description = 4;
  127. v4 := compiler.MapValueForKey(m, "description")
  128. if v4 != nil {
  129. x.Description, ok = v4.(string)
  130. if !ok {
  131. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4)
  132. errors = append(errors, compiler.NewError(context, message))
  133. }
  134. }
  135. // repeated NamedAny vendor_extension = 5;
  136. // MAP: Any ^x-
  137. x.VendorExtension = make([]*NamedAny, 0)
  138. for _, item := range m {
  139. k, ok := compiler.StringValue(item.Key)
  140. if ok {
  141. v := item.Value
  142. if strings.HasPrefix(k, "x-") {
  143. pair := &NamedAny{}
  144. pair.Name = k
  145. result := &Any{}
  146. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  147. if handled {
  148. if err != nil {
  149. errors = append(errors, err)
  150. } else {
  151. bytes, _ := yaml.Marshal(v)
  152. result.Yaml = string(bytes)
  153. result.Value = resultFromExt
  154. pair.Value = result
  155. }
  156. } else {
  157. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  158. if err != nil {
  159. errors = append(errors, err)
  160. }
  161. }
  162. x.VendorExtension = append(x.VendorExtension, pair)
  163. }
  164. }
  165. }
  166. }
  167. return x, compiler.NewErrorGroupOrNil(errors)
  168. }
  169. // NewBasicAuthenticationSecurity creates an object of type BasicAuthenticationSecurity if possible, returning an error if not.
  170. func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) (*BasicAuthenticationSecurity, error) {
  171. errors := make([]error, 0)
  172. x := &BasicAuthenticationSecurity{}
  173. m, ok := compiler.UnpackMap(in)
  174. if !ok {
  175. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  176. errors = append(errors, compiler.NewError(context, message))
  177. } else {
  178. requiredKeys := []string{"type"}
  179. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  180. if len(missingKeys) > 0 {
  181. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  182. errors = append(errors, compiler.NewError(context, message))
  183. }
  184. allowedKeys := []string{"description", "type"}
  185. allowedPatterns := []*regexp.Regexp{pattern0}
  186. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  187. if len(invalidKeys) > 0 {
  188. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  189. errors = append(errors, compiler.NewError(context, message))
  190. }
  191. // string type = 1;
  192. v1 := compiler.MapValueForKey(m, "type")
  193. if v1 != nil {
  194. x.Type, ok = v1.(string)
  195. if !ok {
  196. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  197. errors = append(errors, compiler.NewError(context, message))
  198. }
  199. // check for valid enum values
  200. // [basic]
  201. if ok && !compiler.StringArrayContainsValue([]string{"basic"}, x.Type) {
  202. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  203. errors = append(errors, compiler.NewError(context, message))
  204. }
  205. }
  206. // string description = 2;
  207. v2 := compiler.MapValueForKey(m, "description")
  208. if v2 != nil {
  209. x.Description, ok = v2.(string)
  210. if !ok {
  211. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
  212. errors = append(errors, compiler.NewError(context, message))
  213. }
  214. }
  215. // repeated NamedAny vendor_extension = 3;
  216. // MAP: Any ^x-
  217. x.VendorExtension = make([]*NamedAny, 0)
  218. for _, item := range m {
  219. k, ok := compiler.StringValue(item.Key)
  220. if ok {
  221. v := item.Value
  222. if strings.HasPrefix(k, "x-") {
  223. pair := &NamedAny{}
  224. pair.Name = k
  225. result := &Any{}
  226. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  227. if handled {
  228. if err != nil {
  229. errors = append(errors, err)
  230. } else {
  231. bytes, _ := yaml.Marshal(v)
  232. result.Yaml = string(bytes)
  233. result.Value = resultFromExt
  234. pair.Value = result
  235. }
  236. } else {
  237. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  238. if err != nil {
  239. errors = append(errors, err)
  240. }
  241. }
  242. x.VendorExtension = append(x.VendorExtension, pair)
  243. }
  244. }
  245. }
  246. }
  247. return x, compiler.NewErrorGroupOrNil(errors)
  248. }
  249. // NewBodyParameter creates an object of type BodyParameter if possible, returning an error if not.
  250. func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter, error) {
  251. errors := make([]error, 0)
  252. x := &BodyParameter{}
  253. m, ok := compiler.UnpackMap(in)
  254. if !ok {
  255. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  256. errors = append(errors, compiler.NewError(context, message))
  257. } else {
  258. requiredKeys := []string{"in", "name", "schema"}
  259. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  260. if len(missingKeys) > 0 {
  261. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  262. errors = append(errors, compiler.NewError(context, message))
  263. }
  264. allowedKeys := []string{"description", "in", "name", "required", "schema"}
  265. allowedPatterns := []*regexp.Regexp{pattern0}
  266. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  267. if len(invalidKeys) > 0 {
  268. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  269. errors = append(errors, compiler.NewError(context, message))
  270. }
  271. // string description = 1;
  272. v1 := compiler.MapValueForKey(m, "description")
  273. if v1 != nil {
  274. x.Description, ok = v1.(string)
  275. if !ok {
  276. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
  277. errors = append(errors, compiler.NewError(context, message))
  278. }
  279. }
  280. // string name = 2;
  281. v2 := compiler.MapValueForKey(m, "name")
  282. if v2 != nil {
  283. x.Name, ok = v2.(string)
  284. if !ok {
  285. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2)
  286. errors = append(errors, compiler.NewError(context, message))
  287. }
  288. }
  289. // string in = 3;
  290. v3 := compiler.MapValueForKey(m, "in")
  291. if v3 != nil {
  292. x.In, ok = v3.(string)
  293. if !ok {
  294. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3)
  295. errors = append(errors, compiler.NewError(context, message))
  296. }
  297. // check for valid enum values
  298. // [body]
  299. if ok && !compiler.StringArrayContainsValue([]string{"body"}, x.In) {
  300. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3)
  301. errors = append(errors, compiler.NewError(context, message))
  302. }
  303. }
  304. // bool required = 4;
  305. v4 := compiler.MapValueForKey(m, "required")
  306. if v4 != nil {
  307. x.Required, ok = v4.(bool)
  308. if !ok {
  309. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4)
  310. errors = append(errors, compiler.NewError(context, message))
  311. }
  312. }
  313. // Schema schema = 5;
  314. v5 := compiler.MapValueForKey(m, "schema")
  315. if v5 != nil {
  316. var err error
  317. x.Schema, err = NewSchema(v5, compiler.NewContext("schema", context))
  318. if err != nil {
  319. errors = append(errors, err)
  320. }
  321. }
  322. // repeated NamedAny vendor_extension = 6;
  323. // MAP: Any ^x-
  324. x.VendorExtension = make([]*NamedAny, 0)
  325. for _, item := range m {
  326. k, ok := compiler.StringValue(item.Key)
  327. if ok {
  328. v := item.Value
  329. if strings.HasPrefix(k, "x-") {
  330. pair := &NamedAny{}
  331. pair.Name = k
  332. result := &Any{}
  333. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  334. if handled {
  335. if err != nil {
  336. errors = append(errors, err)
  337. } else {
  338. bytes, _ := yaml.Marshal(v)
  339. result.Yaml = string(bytes)
  340. result.Value = resultFromExt
  341. pair.Value = result
  342. }
  343. } else {
  344. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  345. if err != nil {
  346. errors = append(errors, err)
  347. }
  348. }
  349. x.VendorExtension = append(x.VendorExtension, pair)
  350. }
  351. }
  352. }
  353. }
  354. return x, compiler.NewErrorGroupOrNil(errors)
  355. }
  356. // NewContact creates an object of type Contact if possible, returning an error if not.
  357. func NewContact(in interface{}, context *compiler.Context) (*Contact, error) {
  358. errors := make([]error, 0)
  359. x := &Contact{}
  360. m, ok := compiler.UnpackMap(in)
  361. if !ok {
  362. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  363. errors = append(errors, compiler.NewError(context, message))
  364. } else {
  365. allowedKeys := []string{"email", "name", "url"}
  366. allowedPatterns := []*regexp.Regexp{pattern0}
  367. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  368. if len(invalidKeys) > 0 {
  369. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  370. errors = append(errors, compiler.NewError(context, message))
  371. }
  372. // string name = 1;
  373. v1 := compiler.MapValueForKey(m, "name")
  374. if v1 != nil {
  375. x.Name, ok = v1.(string)
  376. if !ok {
  377. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  378. errors = append(errors, compiler.NewError(context, message))
  379. }
  380. }
  381. // string url = 2;
  382. v2 := compiler.MapValueForKey(m, "url")
  383. if v2 != nil {
  384. x.Url, ok = v2.(string)
  385. if !ok {
  386. message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
  387. errors = append(errors, compiler.NewError(context, message))
  388. }
  389. }
  390. // string email = 3;
  391. v3 := compiler.MapValueForKey(m, "email")
  392. if v3 != nil {
  393. x.Email, ok = v3.(string)
  394. if !ok {
  395. message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3)
  396. errors = append(errors, compiler.NewError(context, message))
  397. }
  398. }
  399. // repeated NamedAny vendor_extension = 4;
  400. // MAP: Any ^x-
  401. x.VendorExtension = make([]*NamedAny, 0)
  402. for _, item := range m {
  403. k, ok := compiler.StringValue(item.Key)
  404. if ok {
  405. v := item.Value
  406. if strings.HasPrefix(k, "x-") {
  407. pair := &NamedAny{}
  408. pair.Name = k
  409. result := &Any{}
  410. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  411. if handled {
  412. if err != nil {
  413. errors = append(errors, err)
  414. } else {
  415. bytes, _ := yaml.Marshal(v)
  416. result.Yaml = string(bytes)
  417. result.Value = resultFromExt
  418. pair.Value = result
  419. }
  420. } else {
  421. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  422. if err != nil {
  423. errors = append(errors, err)
  424. }
  425. }
  426. x.VendorExtension = append(x.VendorExtension, pair)
  427. }
  428. }
  429. }
  430. }
  431. return x, compiler.NewErrorGroupOrNil(errors)
  432. }
  433. // NewDefault creates an object of type Default if possible, returning an error if not.
  434. func NewDefault(in interface{}, context *compiler.Context) (*Default, error) {
  435. errors := make([]error, 0)
  436. x := &Default{}
  437. m, ok := compiler.UnpackMap(in)
  438. if !ok {
  439. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  440. errors = append(errors, compiler.NewError(context, message))
  441. } else {
  442. // repeated NamedAny additional_properties = 1;
  443. // MAP: Any
  444. x.AdditionalProperties = make([]*NamedAny, 0)
  445. for _, item := range m {
  446. k, ok := compiler.StringValue(item.Key)
  447. if ok {
  448. v := item.Value
  449. pair := &NamedAny{}
  450. pair.Name = k
  451. result := &Any{}
  452. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  453. if handled {
  454. if err != nil {
  455. errors = append(errors, err)
  456. } else {
  457. bytes, _ := yaml.Marshal(v)
  458. result.Yaml = string(bytes)
  459. result.Value = resultFromExt
  460. pair.Value = result
  461. }
  462. } else {
  463. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  464. if err != nil {
  465. errors = append(errors, err)
  466. }
  467. }
  468. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  469. }
  470. }
  471. }
  472. return x, compiler.NewErrorGroupOrNil(errors)
  473. }
  474. // NewDefinitions creates an object of type Definitions if possible, returning an error if not.
  475. func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, error) {
  476. errors := make([]error, 0)
  477. x := &Definitions{}
  478. m, ok := compiler.UnpackMap(in)
  479. if !ok {
  480. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  481. errors = append(errors, compiler.NewError(context, message))
  482. } else {
  483. // repeated NamedSchema additional_properties = 1;
  484. // MAP: Schema
  485. x.AdditionalProperties = make([]*NamedSchema, 0)
  486. for _, item := range m {
  487. k, ok := compiler.StringValue(item.Key)
  488. if ok {
  489. v := item.Value
  490. pair := &NamedSchema{}
  491. pair.Name = k
  492. var err error
  493. pair.Value, err = NewSchema(v, compiler.NewContext(k, context))
  494. if err != nil {
  495. errors = append(errors, err)
  496. }
  497. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  498. }
  499. }
  500. }
  501. return x, compiler.NewErrorGroupOrNil(errors)
  502. }
  503. // NewDocument creates an object of type Document if possible, returning an error if not.
  504. func NewDocument(in interface{}, context *compiler.Context) (*Document, error) {
  505. errors := make([]error, 0)
  506. x := &Document{}
  507. m, ok := compiler.UnpackMap(in)
  508. if !ok {
  509. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  510. errors = append(errors, compiler.NewError(context, message))
  511. } else {
  512. requiredKeys := []string{"info", "paths", "swagger"}
  513. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  514. if len(missingKeys) > 0 {
  515. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  516. errors = append(errors, compiler.NewError(context, message))
  517. }
  518. allowedKeys := []string{"basePath", "consumes", "definitions", "externalDocs", "host", "info", "parameters", "paths", "produces", "responses", "schemes", "security", "securityDefinitions", "swagger", "tags"}
  519. allowedPatterns := []*regexp.Regexp{pattern0}
  520. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  521. if len(invalidKeys) > 0 {
  522. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  523. errors = append(errors, compiler.NewError(context, message))
  524. }
  525. // string swagger = 1;
  526. v1 := compiler.MapValueForKey(m, "swagger")
  527. if v1 != nil {
  528. x.Swagger, ok = v1.(string)
  529. if !ok {
  530. message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1)
  531. errors = append(errors, compiler.NewError(context, message))
  532. }
  533. // check for valid enum values
  534. // [2.0]
  535. if ok && !compiler.StringArrayContainsValue([]string{"2.0"}, x.Swagger) {
  536. message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1)
  537. errors = append(errors, compiler.NewError(context, message))
  538. }
  539. }
  540. // Info info = 2;
  541. v2 := compiler.MapValueForKey(m, "info")
  542. if v2 != nil {
  543. var err error
  544. x.Info, err = NewInfo(v2, compiler.NewContext("info", context))
  545. if err != nil {
  546. errors = append(errors, err)
  547. }
  548. }
  549. // string host = 3;
  550. v3 := compiler.MapValueForKey(m, "host")
  551. if v3 != nil {
  552. x.Host, ok = v3.(string)
  553. if !ok {
  554. message := fmt.Sprintf("has unexpected value for host: %+v (%T)", v3, v3)
  555. errors = append(errors, compiler.NewError(context, message))
  556. }
  557. }
  558. // string base_path = 4;
  559. v4 := compiler.MapValueForKey(m, "basePath")
  560. if v4 != nil {
  561. x.BasePath, ok = v4.(string)
  562. if !ok {
  563. message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v4, v4)
  564. errors = append(errors, compiler.NewError(context, message))
  565. }
  566. }
  567. // repeated string schemes = 5;
  568. v5 := compiler.MapValueForKey(m, "schemes")
  569. if v5 != nil {
  570. v, ok := v5.([]interface{})
  571. if ok {
  572. x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v)
  573. } else {
  574. message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v5, v5)
  575. errors = append(errors, compiler.NewError(context, message))
  576. }
  577. // check for valid enum values
  578. // [http https ws wss]
  579. if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) {
  580. message := fmt.Sprintf("has unexpected value for schemes: %+v", v5)
  581. errors = append(errors, compiler.NewError(context, message))
  582. }
  583. }
  584. // repeated string consumes = 6;
  585. v6 := compiler.MapValueForKey(m, "consumes")
  586. if v6 != nil {
  587. v, ok := v6.([]interface{})
  588. if ok {
  589. x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v)
  590. } else {
  591. message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v6, v6)
  592. errors = append(errors, compiler.NewError(context, message))
  593. }
  594. }
  595. // repeated string produces = 7;
  596. v7 := compiler.MapValueForKey(m, "produces")
  597. if v7 != nil {
  598. v, ok := v7.([]interface{})
  599. if ok {
  600. x.Produces = compiler.ConvertInterfaceArrayToStringArray(v)
  601. } else {
  602. message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v7, v7)
  603. errors = append(errors, compiler.NewError(context, message))
  604. }
  605. }
  606. // Paths paths = 8;
  607. v8 := compiler.MapValueForKey(m, "paths")
  608. if v8 != nil {
  609. var err error
  610. x.Paths, err = NewPaths(v8, compiler.NewContext("paths", context))
  611. if err != nil {
  612. errors = append(errors, err)
  613. }
  614. }
  615. // Definitions definitions = 9;
  616. v9 := compiler.MapValueForKey(m, "definitions")
  617. if v9 != nil {
  618. var err error
  619. x.Definitions, err = NewDefinitions(v9, compiler.NewContext("definitions", context))
  620. if err != nil {
  621. errors = append(errors, err)
  622. }
  623. }
  624. // ParameterDefinitions parameters = 10;
  625. v10 := compiler.MapValueForKey(m, "parameters")
  626. if v10 != nil {
  627. var err error
  628. x.Parameters, err = NewParameterDefinitions(v10, compiler.NewContext("parameters", context))
  629. if err != nil {
  630. errors = append(errors, err)
  631. }
  632. }
  633. // ResponseDefinitions responses = 11;
  634. v11 := compiler.MapValueForKey(m, "responses")
  635. if v11 != nil {
  636. var err error
  637. x.Responses, err = NewResponseDefinitions(v11, compiler.NewContext("responses", context))
  638. if err != nil {
  639. errors = append(errors, err)
  640. }
  641. }
  642. // repeated SecurityRequirement security = 12;
  643. v12 := compiler.MapValueForKey(m, "security")
  644. if v12 != nil {
  645. // repeated SecurityRequirement
  646. x.Security = make([]*SecurityRequirement, 0)
  647. a, ok := v12.([]interface{})
  648. if ok {
  649. for _, item := range a {
  650. y, err := NewSecurityRequirement(item, compiler.NewContext("security", context))
  651. if err != nil {
  652. errors = append(errors, err)
  653. }
  654. x.Security = append(x.Security, y)
  655. }
  656. }
  657. }
  658. // SecurityDefinitions security_definitions = 13;
  659. v13 := compiler.MapValueForKey(m, "securityDefinitions")
  660. if v13 != nil {
  661. var err error
  662. x.SecurityDefinitions, err = NewSecurityDefinitions(v13, compiler.NewContext("securityDefinitions", context))
  663. if err != nil {
  664. errors = append(errors, err)
  665. }
  666. }
  667. // repeated Tag tags = 14;
  668. v14 := compiler.MapValueForKey(m, "tags")
  669. if v14 != nil {
  670. // repeated Tag
  671. x.Tags = make([]*Tag, 0)
  672. a, ok := v14.([]interface{})
  673. if ok {
  674. for _, item := range a {
  675. y, err := NewTag(item, compiler.NewContext("tags", context))
  676. if err != nil {
  677. errors = append(errors, err)
  678. }
  679. x.Tags = append(x.Tags, y)
  680. }
  681. }
  682. }
  683. // ExternalDocs external_docs = 15;
  684. v15 := compiler.MapValueForKey(m, "externalDocs")
  685. if v15 != nil {
  686. var err error
  687. x.ExternalDocs, err = NewExternalDocs(v15, compiler.NewContext("externalDocs", context))
  688. if err != nil {
  689. errors = append(errors, err)
  690. }
  691. }
  692. // repeated NamedAny vendor_extension = 16;
  693. // MAP: Any ^x-
  694. x.VendorExtension = make([]*NamedAny, 0)
  695. for _, item := range m {
  696. k, ok := compiler.StringValue(item.Key)
  697. if ok {
  698. v := item.Value
  699. if strings.HasPrefix(k, "x-") {
  700. pair := &NamedAny{}
  701. pair.Name = k
  702. result := &Any{}
  703. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  704. if handled {
  705. if err != nil {
  706. errors = append(errors, err)
  707. } else {
  708. bytes, _ := yaml.Marshal(v)
  709. result.Yaml = string(bytes)
  710. result.Value = resultFromExt
  711. pair.Value = result
  712. }
  713. } else {
  714. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  715. if err != nil {
  716. errors = append(errors, err)
  717. }
  718. }
  719. x.VendorExtension = append(x.VendorExtension, pair)
  720. }
  721. }
  722. }
  723. }
  724. return x, compiler.NewErrorGroupOrNil(errors)
  725. }
  726. // NewExamples creates an object of type Examples if possible, returning an error if not.
  727. func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) {
  728. errors := make([]error, 0)
  729. x := &Examples{}
  730. m, ok := compiler.UnpackMap(in)
  731. if !ok {
  732. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  733. errors = append(errors, compiler.NewError(context, message))
  734. } else {
  735. // repeated NamedAny additional_properties = 1;
  736. // MAP: Any
  737. x.AdditionalProperties = make([]*NamedAny, 0)
  738. for _, item := range m {
  739. k, ok := compiler.StringValue(item.Key)
  740. if ok {
  741. v := item.Value
  742. pair := &NamedAny{}
  743. pair.Name = k
  744. result := &Any{}
  745. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  746. if handled {
  747. if err != nil {
  748. errors = append(errors, err)
  749. } else {
  750. bytes, _ := yaml.Marshal(v)
  751. result.Yaml = string(bytes)
  752. result.Value = resultFromExt
  753. pair.Value = result
  754. }
  755. } else {
  756. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  757. if err != nil {
  758. errors = append(errors, err)
  759. }
  760. }
  761. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  762. }
  763. }
  764. }
  765. return x, compiler.NewErrorGroupOrNil(errors)
  766. }
  767. // NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not.
  768. func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) {
  769. errors := make([]error, 0)
  770. x := &ExternalDocs{}
  771. m, ok := compiler.UnpackMap(in)
  772. if !ok {
  773. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  774. errors = append(errors, compiler.NewError(context, message))
  775. } else {
  776. requiredKeys := []string{"url"}
  777. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  778. if len(missingKeys) > 0 {
  779. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  780. errors = append(errors, compiler.NewError(context, message))
  781. }
  782. allowedKeys := []string{"description", "url"}
  783. allowedPatterns := []*regexp.Regexp{pattern0}
  784. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  785. if len(invalidKeys) > 0 {
  786. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  787. errors = append(errors, compiler.NewError(context, message))
  788. }
  789. // string description = 1;
  790. v1 := compiler.MapValueForKey(m, "description")
  791. if v1 != nil {
  792. x.Description, ok = v1.(string)
  793. if !ok {
  794. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
  795. errors = append(errors, compiler.NewError(context, message))
  796. }
  797. }
  798. // string url = 2;
  799. v2 := compiler.MapValueForKey(m, "url")
  800. if v2 != nil {
  801. x.Url, ok = v2.(string)
  802. if !ok {
  803. message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
  804. errors = append(errors, compiler.NewError(context, message))
  805. }
  806. }
  807. // repeated NamedAny vendor_extension = 3;
  808. // MAP: Any ^x-
  809. x.VendorExtension = make([]*NamedAny, 0)
  810. for _, item := range m {
  811. k, ok := compiler.StringValue(item.Key)
  812. if ok {
  813. v := item.Value
  814. if strings.HasPrefix(k, "x-") {
  815. pair := &NamedAny{}
  816. pair.Name = k
  817. result := &Any{}
  818. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  819. if handled {
  820. if err != nil {
  821. errors = append(errors, err)
  822. } else {
  823. bytes, _ := yaml.Marshal(v)
  824. result.Yaml = string(bytes)
  825. result.Value = resultFromExt
  826. pair.Value = result
  827. }
  828. } else {
  829. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  830. if err != nil {
  831. errors = append(errors, err)
  832. }
  833. }
  834. x.VendorExtension = append(x.VendorExtension, pair)
  835. }
  836. }
  837. }
  838. }
  839. return x, compiler.NewErrorGroupOrNil(errors)
  840. }
  841. // NewFileSchema creates an object of type FileSchema if possible, returning an error if not.
  842. func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, error) {
  843. errors := make([]error, 0)
  844. x := &FileSchema{}
  845. m, ok := compiler.UnpackMap(in)
  846. if !ok {
  847. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  848. errors = append(errors, compiler.NewError(context, message))
  849. } else {
  850. requiredKeys := []string{"type"}
  851. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  852. if len(missingKeys) > 0 {
  853. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  854. errors = append(errors, compiler.NewError(context, message))
  855. }
  856. allowedKeys := []string{"default", "description", "example", "externalDocs", "format", "readOnly", "required", "title", "type"}
  857. allowedPatterns := []*regexp.Regexp{pattern0}
  858. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  859. if len(invalidKeys) > 0 {
  860. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  861. errors = append(errors, compiler.NewError(context, message))
  862. }
  863. // string format = 1;
  864. v1 := compiler.MapValueForKey(m, "format")
  865. if v1 != nil {
  866. x.Format, ok = v1.(string)
  867. if !ok {
  868. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v1, v1)
  869. errors = append(errors, compiler.NewError(context, message))
  870. }
  871. }
  872. // string title = 2;
  873. v2 := compiler.MapValueForKey(m, "title")
  874. if v2 != nil {
  875. x.Title, ok = v2.(string)
  876. if !ok {
  877. message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v2, v2)
  878. errors = append(errors, compiler.NewError(context, message))
  879. }
  880. }
  881. // string description = 3;
  882. v3 := compiler.MapValueForKey(m, "description")
  883. if v3 != nil {
  884. x.Description, ok = v3.(string)
  885. if !ok {
  886. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  887. errors = append(errors, compiler.NewError(context, message))
  888. }
  889. }
  890. // Any default = 4;
  891. v4 := compiler.MapValueForKey(m, "default")
  892. if v4 != nil {
  893. var err error
  894. x.Default, err = NewAny(v4, compiler.NewContext("default", context))
  895. if err != nil {
  896. errors = append(errors, err)
  897. }
  898. }
  899. // repeated string required = 5;
  900. v5 := compiler.MapValueForKey(m, "required")
  901. if v5 != nil {
  902. v, ok := v5.([]interface{})
  903. if ok {
  904. x.Required = compiler.ConvertInterfaceArrayToStringArray(v)
  905. } else {
  906. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5)
  907. errors = append(errors, compiler.NewError(context, message))
  908. }
  909. }
  910. // string type = 6;
  911. v6 := compiler.MapValueForKey(m, "type")
  912. if v6 != nil {
  913. x.Type, ok = v6.(string)
  914. if !ok {
  915. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  916. errors = append(errors, compiler.NewError(context, message))
  917. }
  918. // check for valid enum values
  919. // [file]
  920. if ok && !compiler.StringArrayContainsValue([]string{"file"}, x.Type) {
  921. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  922. errors = append(errors, compiler.NewError(context, message))
  923. }
  924. }
  925. // bool read_only = 7;
  926. v7 := compiler.MapValueForKey(m, "readOnly")
  927. if v7 != nil {
  928. x.ReadOnly, ok = v7.(bool)
  929. if !ok {
  930. message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v7, v7)
  931. errors = append(errors, compiler.NewError(context, message))
  932. }
  933. }
  934. // ExternalDocs external_docs = 8;
  935. v8 := compiler.MapValueForKey(m, "externalDocs")
  936. if v8 != nil {
  937. var err error
  938. x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", context))
  939. if err != nil {
  940. errors = append(errors, err)
  941. }
  942. }
  943. // Any example = 9;
  944. v9 := compiler.MapValueForKey(m, "example")
  945. if v9 != nil {
  946. var err error
  947. x.Example, err = NewAny(v9, compiler.NewContext("example", context))
  948. if err != nil {
  949. errors = append(errors, err)
  950. }
  951. }
  952. // repeated NamedAny vendor_extension = 10;
  953. // MAP: Any ^x-
  954. x.VendorExtension = make([]*NamedAny, 0)
  955. for _, item := range m {
  956. k, ok := compiler.StringValue(item.Key)
  957. if ok {
  958. v := item.Value
  959. if strings.HasPrefix(k, "x-") {
  960. pair := &NamedAny{}
  961. pair.Name = k
  962. result := &Any{}
  963. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  964. if handled {
  965. if err != nil {
  966. errors = append(errors, err)
  967. } else {
  968. bytes, _ := yaml.Marshal(v)
  969. result.Yaml = string(bytes)
  970. result.Value = resultFromExt
  971. pair.Value = result
  972. }
  973. } else {
  974. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  975. if err != nil {
  976. errors = append(errors, err)
  977. }
  978. }
  979. x.VendorExtension = append(x.VendorExtension, pair)
  980. }
  981. }
  982. }
  983. }
  984. return x, compiler.NewErrorGroupOrNil(errors)
  985. }
  986. // NewFormDataParameterSubSchema creates an object of type FormDataParameterSubSchema if possible, returning an error if not.
  987. func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (*FormDataParameterSubSchema, error) {
  988. errors := make([]error, 0)
  989. x := &FormDataParameterSubSchema{}
  990. m, ok := compiler.UnpackMap(in)
  991. if !ok {
  992. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  993. errors = append(errors, compiler.NewError(context, message))
  994. } else {
  995. allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"}
  996. allowedPatterns := []*regexp.Regexp{pattern0}
  997. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  998. if len(invalidKeys) > 0 {
  999. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  1000. errors = append(errors, compiler.NewError(context, message))
  1001. }
  1002. // bool required = 1;
  1003. v1 := compiler.MapValueForKey(m, "required")
  1004. if v1 != nil {
  1005. x.Required, ok = v1.(bool)
  1006. if !ok {
  1007. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1)
  1008. errors = append(errors, compiler.NewError(context, message))
  1009. }
  1010. }
  1011. // string in = 2;
  1012. v2 := compiler.MapValueForKey(m, "in")
  1013. if v2 != nil {
  1014. x.In, ok = v2.(string)
  1015. if !ok {
  1016. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  1017. errors = append(errors, compiler.NewError(context, message))
  1018. }
  1019. // check for valid enum values
  1020. // [formData]
  1021. if ok && !compiler.StringArrayContainsValue([]string{"formData"}, x.In) {
  1022. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  1023. errors = append(errors, compiler.NewError(context, message))
  1024. }
  1025. }
  1026. // string description = 3;
  1027. v3 := compiler.MapValueForKey(m, "description")
  1028. if v3 != nil {
  1029. x.Description, ok = v3.(string)
  1030. if !ok {
  1031. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  1032. errors = append(errors, compiler.NewError(context, message))
  1033. }
  1034. }
  1035. // string name = 4;
  1036. v4 := compiler.MapValueForKey(m, "name")
  1037. if v4 != nil {
  1038. x.Name, ok = v4.(string)
  1039. if !ok {
  1040. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4)
  1041. errors = append(errors, compiler.NewError(context, message))
  1042. }
  1043. }
  1044. // bool allow_empty_value = 5;
  1045. v5 := compiler.MapValueForKey(m, "allowEmptyValue")
  1046. if v5 != nil {
  1047. x.AllowEmptyValue, ok = v5.(bool)
  1048. if !ok {
  1049. message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5)
  1050. errors = append(errors, compiler.NewError(context, message))
  1051. }
  1052. }
  1053. // string type = 6;
  1054. v6 := compiler.MapValueForKey(m, "type")
  1055. if v6 != nil {
  1056. x.Type, ok = v6.(string)
  1057. if !ok {
  1058. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  1059. errors = append(errors, compiler.NewError(context, message))
  1060. }
  1061. // check for valid enum values
  1062. // [string number boolean integer array file]
  1063. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array", "file"}, x.Type) {
  1064. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  1065. errors = append(errors, compiler.NewError(context, message))
  1066. }
  1067. }
  1068. // string format = 7;
  1069. v7 := compiler.MapValueForKey(m, "format")
  1070. if v7 != nil {
  1071. x.Format, ok = v7.(string)
  1072. if !ok {
  1073. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7)
  1074. errors = append(errors, compiler.NewError(context, message))
  1075. }
  1076. }
  1077. // PrimitivesItems items = 8;
  1078. v8 := compiler.MapValueForKey(m, "items")
  1079. if v8 != nil {
  1080. var err error
  1081. x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context))
  1082. if err != nil {
  1083. errors = append(errors, err)
  1084. }
  1085. }
  1086. // string collection_format = 9;
  1087. v9 := compiler.MapValueForKey(m, "collectionFormat")
  1088. if v9 != nil {
  1089. x.CollectionFormat, ok = v9.(string)
  1090. if !ok {
  1091. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9)
  1092. errors = append(errors, compiler.NewError(context, message))
  1093. }
  1094. // check for valid enum values
  1095. // [csv ssv tsv pipes multi]
  1096. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) {
  1097. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9)
  1098. errors = append(errors, compiler.NewError(context, message))
  1099. }
  1100. }
  1101. // Any default = 10;
  1102. v10 := compiler.MapValueForKey(m, "default")
  1103. if v10 != nil {
  1104. var err error
  1105. x.Default, err = NewAny(v10, compiler.NewContext("default", context))
  1106. if err != nil {
  1107. errors = append(errors, err)
  1108. }
  1109. }
  1110. // float maximum = 11;
  1111. v11 := compiler.MapValueForKey(m, "maximum")
  1112. if v11 != nil {
  1113. switch v11 := v11.(type) {
  1114. case float64:
  1115. x.Maximum = v11
  1116. case float32:
  1117. x.Maximum = float64(v11)
  1118. case uint64:
  1119. x.Maximum = float64(v11)
  1120. case uint32:
  1121. x.Maximum = float64(v11)
  1122. case int64:
  1123. x.Maximum = float64(v11)
  1124. case int32:
  1125. x.Maximum = float64(v11)
  1126. case int:
  1127. x.Maximum = float64(v11)
  1128. default:
  1129. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11)
  1130. errors = append(errors, compiler.NewError(context, message))
  1131. }
  1132. }
  1133. // bool exclusive_maximum = 12;
  1134. v12 := compiler.MapValueForKey(m, "exclusiveMaximum")
  1135. if v12 != nil {
  1136. x.ExclusiveMaximum, ok = v12.(bool)
  1137. if !ok {
  1138. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12)
  1139. errors = append(errors, compiler.NewError(context, message))
  1140. }
  1141. }
  1142. // float minimum = 13;
  1143. v13 := compiler.MapValueForKey(m, "minimum")
  1144. if v13 != nil {
  1145. switch v13 := v13.(type) {
  1146. case float64:
  1147. x.Minimum = v13
  1148. case float32:
  1149. x.Minimum = float64(v13)
  1150. case uint64:
  1151. x.Minimum = float64(v13)
  1152. case uint32:
  1153. x.Minimum = float64(v13)
  1154. case int64:
  1155. x.Minimum = float64(v13)
  1156. case int32:
  1157. x.Minimum = float64(v13)
  1158. case int:
  1159. x.Minimum = float64(v13)
  1160. default:
  1161. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13)
  1162. errors = append(errors, compiler.NewError(context, message))
  1163. }
  1164. }
  1165. // bool exclusive_minimum = 14;
  1166. v14 := compiler.MapValueForKey(m, "exclusiveMinimum")
  1167. if v14 != nil {
  1168. x.ExclusiveMinimum, ok = v14.(bool)
  1169. if !ok {
  1170. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14)
  1171. errors = append(errors, compiler.NewError(context, message))
  1172. }
  1173. }
  1174. // int64 max_length = 15;
  1175. v15 := compiler.MapValueForKey(m, "maxLength")
  1176. if v15 != nil {
  1177. t, ok := v15.(int)
  1178. if ok {
  1179. x.MaxLength = int64(t)
  1180. } else {
  1181. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15)
  1182. errors = append(errors, compiler.NewError(context, message))
  1183. }
  1184. }
  1185. // int64 min_length = 16;
  1186. v16 := compiler.MapValueForKey(m, "minLength")
  1187. if v16 != nil {
  1188. t, ok := v16.(int)
  1189. if ok {
  1190. x.MinLength = int64(t)
  1191. } else {
  1192. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16)
  1193. errors = append(errors, compiler.NewError(context, message))
  1194. }
  1195. }
  1196. // string pattern = 17;
  1197. v17 := compiler.MapValueForKey(m, "pattern")
  1198. if v17 != nil {
  1199. x.Pattern, ok = v17.(string)
  1200. if !ok {
  1201. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17)
  1202. errors = append(errors, compiler.NewError(context, message))
  1203. }
  1204. }
  1205. // int64 max_items = 18;
  1206. v18 := compiler.MapValueForKey(m, "maxItems")
  1207. if v18 != nil {
  1208. t, ok := v18.(int)
  1209. if ok {
  1210. x.MaxItems = int64(t)
  1211. } else {
  1212. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18)
  1213. errors = append(errors, compiler.NewError(context, message))
  1214. }
  1215. }
  1216. // int64 min_items = 19;
  1217. v19 := compiler.MapValueForKey(m, "minItems")
  1218. if v19 != nil {
  1219. t, ok := v19.(int)
  1220. if ok {
  1221. x.MinItems = int64(t)
  1222. } else {
  1223. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19)
  1224. errors = append(errors, compiler.NewError(context, message))
  1225. }
  1226. }
  1227. // bool unique_items = 20;
  1228. v20 := compiler.MapValueForKey(m, "uniqueItems")
  1229. if v20 != nil {
  1230. x.UniqueItems, ok = v20.(bool)
  1231. if !ok {
  1232. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20)
  1233. errors = append(errors, compiler.NewError(context, message))
  1234. }
  1235. }
  1236. // repeated Any enum = 21;
  1237. v21 := compiler.MapValueForKey(m, "enum")
  1238. if v21 != nil {
  1239. // repeated Any
  1240. x.Enum = make([]*Any, 0)
  1241. a, ok := v21.([]interface{})
  1242. if ok {
  1243. for _, item := range a {
  1244. y, err := NewAny(item, compiler.NewContext("enum", context))
  1245. if err != nil {
  1246. errors = append(errors, err)
  1247. }
  1248. x.Enum = append(x.Enum, y)
  1249. }
  1250. }
  1251. }
  1252. // float multiple_of = 22;
  1253. v22 := compiler.MapValueForKey(m, "multipleOf")
  1254. if v22 != nil {
  1255. switch v22 := v22.(type) {
  1256. case float64:
  1257. x.MultipleOf = v22
  1258. case float32:
  1259. x.MultipleOf = float64(v22)
  1260. case uint64:
  1261. x.MultipleOf = float64(v22)
  1262. case uint32:
  1263. x.MultipleOf = float64(v22)
  1264. case int64:
  1265. x.MultipleOf = float64(v22)
  1266. case int32:
  1267. x.MultipleOf = float64(v22)
  1268. case int:
  1269. x.MultipleOf = float64(v22)
  1270. default:
  1271. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22)
  1272. errors = append(errors, compiler.NewError(context, message))
  1273. }
  1274. }
  1275. // repeated NamedAny vendor_extension = 23;
  1276. // MAP: Any ^x-
  1277. x.VendorExtension = make([]*NamedAny, 0)
  1278. for _, item := range m {
  1279. k, ok := compiler.StringValue(item.Key)
  1280. if ok {
  1281. v := item.Value
  1282. if strings.HasPrefix(k, "x-") {
  1283. pair := &NamedAny{}
  1284. pair.Name = k
  1285. result := &Any{}
  1286. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  1287. if handled {
  1288. if err != nil {
  1289. errors = append(errors, err)
  1290. } else {
  1291. bytes, _ := yaml.Marshal(v)
  1292. result.Yaml = string(bytes)
  1293. result.Value = resultFromExt
  1294. pair.Value = result
  1295. }
  1296. } else {
  1297. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  1298. if err != nil {
  1299. errors = append(errors, err)
  1300. }
  1301. }
  1302. x.VendorExtension = append(x.VendorExtension, pair)
  1303. }
  1304. }
  1305. }
  1306. }
  1307. return x, compiler.NewErrorGroupOrNil(errors)
  1308. }
  1309. // NewHeader creates an object of type Header if possible, returning an error if not.
  1310. func NewHeader(in interface{}, context *compiler.Context) (*Header, error) {
  1311. errors := make([]error, 0)
  1312. x := &Header{}
  1313. m, ok := compiler.UnpackMap(in)
  1314. if !ok {
  1315. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  1316. errors = append(errors, compiler.NewError(context, message))
  1317. } else {
  1318. requiredKeys := []string{"type"}
  1319. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  1320. if len(missingKeys) > 0 {
  1321. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  1322. errors = append(errors, compiler.NewError(context, message))
  1323. }
  1324. allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"}
  1325. allowedPatterns := []*regexp.Regexp{pattern0}
  1326. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  1327. if len(invalidKeys) > 0 {
  1328. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  1329. errors = append(errors, compiler.NewError(context, message))
  1330. }
  1331. // string type = 1;
  1332. v1 := compiler.MapValueForKey(m, "type")
  1333. if v1 != nil {
  1334. x.Type, ok = v1.(string)
  1335. if !ok {
  1336. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  1337. errors = append(errors, compiler.NewError(context, message))
  1338. }
  1339. // check for valid enum values
  1340. // [string number integer boolean array]
  1341. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) {
  1342. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  1343. errors = append(errors, compiler.NewError(context, message))
  1344. }
  1345. }
  1346. // string format = 2;
  1347. v2 := compiler.MapValueForKey(m, "format")
  1348. if v2 != nil {
  1349. x.Format, ok = v2.(string)
  1350. if !ok {
  1351. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2)
  1352. errors = append(errors, compiler.NewError(context, message))
  1353. }
  1354. }
  1355. // PrimitivesItems items = 3;
  1356. v3 := compiler.MapValueForKey(m, "items")
  1357. if v3 != nil {
  1358. var err error
  1359. x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context))
  1360. if err != nil {
  1361. errors = append(errors, err)
  1362. }
  1363. }
  1364. // string collection_format = 4;
  1365. v4 := compiler.MapValueForKey(m, "collectionFormat")
  1366. if v4 != nil {
  1367. x.CollectionFormat, ok = v4.(string)
  1368. if !ok {
  1369. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4)
  1370. errors = append(errors, compiler.NewError(context, message))
  1371. }
  1372. // check for valid enum values
  1373. // [csv ssv tsv pipes]
  1374. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) {
  1375. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4)
  1376. errors = append(errors, compiler.NewError(context, message))
  1377. }
  1378. }
  1379. // Any default = 5;
  1380. v5 := compiler.MapValueForKey(m, "default")
  1381. if v5 != nil {
  1382. var err error
  1383. x.Default, err = NewAny(v5, compiler.NewContext("default", context))
  1384. if err != nil {
  1385. errors = append(errors, err)
  1386. }
  1387. }
  1388. // float maximum = 6;
  1389. v6 := compiler.MapValueForKey(m, "maximum")
  1390. if v6 != nil {
  1391. switch v6 := v6.(type) {
  1392. case float64:
  1393. x.Maximum = v6
  1394. case float32:
  1395. x.Maximum = float64(v6)
  1396. case uint64:
  1397. x.Maximum = float64(v6)
  1398. case uint32:
  1399. x.Maximum = float64(v6)
  1400. case int64:
  1401. x.Maximum = float64(v6)
  1402. case int32:
  1403. x.Maximum = float64(v6)
  1404. case int:
  1405. x.Maximum = float64(v6)
  1406. default:
  1407. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6)
  1408. errors = append(errors, compiler.NewError(context, message))
  1409. }
  1410. }
  1411. // bool exclusive_maximum = 7;
  1412. v7 := compiler.MapValueForKey(m, "exclusiveMaximum")
  1413. if v7 != nil {
  1414. x.ExclusiveMaximum, ok = v7.(bool)
  1415. if !ok {
  1416. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7)
  1417. errors = append(errors, compiler.NewError(context, message))
  1418. }
  1419. }
  1420. // float minimum = 8;
  1421. v8 := compiler.MapValueForKey(m, "minimum")
  1422. if v8 != nil {
  1423. switch v8 := v8.(type) {
  1424. case float64:
  1425. x.Minimum = v8
  1426. case float32:
  1427. x.Minimum = float64(v8)
  1428. case uint64:
  1429. x.Minimum = float64(v8)
  1430. case uint32:
  1431. x.Minimum = float64(v8)
  1432. case int64:
  1433. x.Minimum = float64(v8)
  1434. case int32:
  1435. x.Minimum = float64(v8)
  1436. case int:
  1437. x.Minimum = float64(v8)
  1438. default:
  1439. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8)
  1440. errors = append(errors, compiler.NewError(context, message))
  1441. }
  1442. }
  1443. // bool exclusive_minimum = 9;
  1444. v9 := compiler.MapValueForKey(m, "exclusiveMinimum")
  1445. if v9 != nil {
  1446. x.ExclusiveMinimum, ok = v9.(bool)
  1447. if !ok {
  1448. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9)
  1449. errors = append(errors, compiler.NewError(context, message))
  1450. }
  1451. }
  1452. // int64 max_length = 10;
  1453. v10 := compiler.MapValueForKey(m, "maxLength")
  1454. if v10 != nil {
  1455. t, ok := v10.(int)
  1456. if ok {
  1457. x.MaxLength = int64(t)
  1458. } else {
  1459. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10)
  1460. errors = append(errors, compiler.NewError(context, message))
  1461. }
  1462. }
  1463. // int64 min_length = 11;
  1464. v11 := compiler.MapValueForKey(m, "minLength")
  1465. if v11 != nil {
  1466. t, ok := v11.(int)
  1467. if ok {
  1468. x.MinLength = int64(t)
  1469. } else {
  1470. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11)
  1471. errors = append(errors, compiler.NewError(context, message))
  1472. }
  1473. }
  1474. // string pattern = 12;
  1475. v12 := compiler.MapValueForKey(m, "pattern")
  1476. if v12 != nil {
  1477. x.Pattern, ok = v12.(string)
  1478. if !ok {
  1479. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12)
  1480. errors = append(errors, compiler.NewError(context, message))
  1481. }
  1482. }
  1483. // int64 max_items = 13;
  1484. v13 := compiler.MapValueForKey(m, "maxItems")
  1485. if v13 != nil {
  1486. t, ok := v13.(int)
  1487. if ok {
  1488. x.MaxItems = int64(t)
  1489. } else {
  1490. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13)
  1491. errors = append(errors, compiler.NewError(context, message))
  1492. }
  1493. }
  1494. // int64 min_items = 14;
  1495. v14 := compiler.MapValueForKey(m, "minItems")
  1496. if v14 != nil {
  1497. t, ok := v14.(int)
  1498. if ok {
  1499. x.MinItems = int64(t)
  1500. } else {
  1501. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14)
  1502. errors = append(errors, compiler.NewError(context, message))
  1503. }
  1504. }
  1505. // bool unique_items = 15;
  1506. v15 := compiler.MapValueForKey(m, "uniqueItems")
  1507. if v15 != nil {
  1508. x.UniqueItems, ok = v15.(bool)
  1509. if !ok {
  1510. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15)
  1511. errors = append(errors, compiler.NewError(context, message))
  1512. }
  1513. }
  1514. // repeated Any enum = 16;
  1515. v16 := compiler.MapValueForKey(m, "enum")
  1516. if v16 != nil {
  1517. // repeated Any
  1518. x.Enum = make([]*Any, 0)
  1519. a, ok := v16.([]interface{})
  1520. if ok {
  1521. for _, item := range a {
  1522. y, err := NewAny(item, compiler.NewContext("enum", context))
  1523. if err != nil {
  1524. errors = append(errors, err)
  1525. }
  1526. x.Enum = append(x.Enum, y)
  1527. }
  1528. }
  1529. }
  1530. // float multiple_of = 17;
  1531. v17 := compiler.MapValueForKey(m, "multipleOf")
  1532. if v17 != nil {
  1533. switch v17 := v17.(type) {
  1534. case float64:
  1535. x.MultipleOf = v17
  1536. case float32:
  1537. x.MultipleOf = float64(v17)
  1538. case uint64:
  1539. x.MultipleOf = float64(v17)
  1540. case uint32:
  1541. x.MultipleOf = float64(v17)
  1542. case int64:
  1543. x.MultipleOf = float64(v17)
  1544. case int32:
  1545. x.MultipleOf = float64(v17)
  1546. case int:
  1547. x.MultipleOf = float64(v17)
  1548. default:
  1549. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17)
  1550. errors = append(errors, compiler.NewError(context, message))
  1551. }
  1552. }
  1553. // string description = 18;
  1554. v18 := compiler.MapValueForKey(m, "description")
  1555. if v18 != nil {
  1556. x.Description, ok = v18.(string)
  1557. if !ok {
  1558. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v18, v18)
  1559. errors = append(errors, compiler.NewError(context, message))
  1560. }
  1561. }
  1562. // repeated NamedAny vendor_extension = 19;
  1563. // MAP: Any ^x-
  1564. x.VendorExtension = make([]*NamedAny, 0)
  1565. for _, item := range m {
  1566. k, ok := compiler.StringValue(item.Key)
  1567. if ok {
  1568. v := item.Value
  1569. if strings.HasPrefix(k, "x-") {
  1570. pair := &NamedAny{}
  1571. pair.Name = k
  1572. result := &Any{}
  1573. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  1574. if handled {
  1575. if err != nil {
  1576. errors = append(errors, err)
  1577. } else {
  1578. bytes, _ := yaml.Marshal(v)
  1579. result.Yaml = string(bytes)
  1580. result.Value = resultFromExt
  1581. pair.Value = result
  1582. }
  1583. } else {
  1584. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  1585. if err != nil {
  1586. errors = append(errors, err)
  1587. }
  1588. }
  1589. x.VendorExtension = append(x.VendorExtension, pair)
  1590. }
  1591. }
  1592. }
  1593. }
  1594. return x, compiler.NewErrorGroupOrNil(errors)
  1595. }
  1596. // NewHeaderParameterSubSchema creates an object of type HeaderParameterSubSchema if possible, returning an error if not.
  1597. func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*HeaderParameterSubSchema, error) {
  1598. errors := make([]error, 0)
  1599. x := &HeaderParameterSubSchema{}
  1600. m, ok := compiler.UnpackMap(in)
  1601. if !ok {
  1602. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  1603. errors = append(errors, compiler.NewError(context, message))
  1604. } else {
  1605. allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"}
  1606. allowedPatterns := []*regexp.Regexp{pattern0}
  1607. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  1608. if len(invalidKeys) > 0 {
  1609. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  1610. errors = append(errors, compiler.NewError(context, message))
  1611. }
  1612. // bool required = 1;
  1613. v1 := compiler.MapValueForKey(m, "required")
  1614. if v1 != nil {
  1615. x.Required, ok = v1.(bool)
  1616. if !ok {
  1617. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1)
  1618. errors = append(errors, compiler.NewError(context, message))
  1619. }
  1620. }
  1621. // string in = 2;
  1622. v2 := compiler.MapValueForKey(m, "in")
  1623. if v2 != nil {
  1624. x.In, ok = v2.(string)
  1625. if !ok {
  1626. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  1627. errors = append(errors, compiler.NewError(context, message))
  1628. }
  1629. // check for valid enum values
  1630. // [header]
  1631. if ok && !compiler.StringArrayContainsValue([]string{"header"}, x.In) {
  1632. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  1633. errors = append(errors, compiler.NewError(context, message))
  1634. }
  1635. }
  1636. // string description = 3;
  1637. v3 := compiler.MapValueForKey(m, "description")
  1638. if v3 != nil {
  1639. x.Description, ok = v3.(string)
  1640. if !ok {
  1641. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  1642. errors = append(errors, compiler.NewError(context, message))
  1643. }
  1644. }
  1645. // string name = 4;
  1646. v4 := compiler.MapValueForKey(m, "name")
  1647. if v4 != nil {
  1648. x.Name, ok = v4.(string)
  1649. if !ok {
  1650. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4)
  1651. errors = append(errors, compiler.NewError(context, message))
  1652. }
  1653. }
  1654. // string type = 5;
  1655. v5 := compiler.MapValueForKey(m, "type")
  1656. if v5 != nil {
  1657. x.Type, ok = v5.(string)
  1658. if !ok {
  1659. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5)
  1660. errors = append(errors, compiler.NewError(context, message))
  1661. }
  1662. // check for valid enum values
  1663. // [string number boolean integer array]
  1664. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) {
  1665. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5)
  1666. errors = append(errors, compiler.NewError(context, message))
  1667. }
  1668. }
  1669. // string format = 6;
  1670. v6 := compiler.MapValueForKey(m, "format")
  1671. if v6 != nil {
  1672. x.Format, ok = v6.(string)
  1673. if !ok {
  1674. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6)
  1675. errors = append(errors, compiler.NewError(context, message))
  1676. }
  1677. }
  1678. // PrimitivesItems items = 7;
  1679. v7 := compiler.MapValueForKey(m, "items")
  1680. if v7 != nil {
  1681. var err error
  1682. x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context))
  1683. if err != nil {
  1684. errors = append(errors, err)
  1685. }
  1686. }
  1687. // string collection_format = 8;
  1688. v8 := compiler.MapValueForKey(m, "collectionFormat")
  1689. if v8 != nil {
  1690. x.CollectionFormat, ok = v8.(string)
  1691. if !ok {
  1692. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8)
  1693. errors = append(errors, compiler.NewError(context, message))
  1694. }
  1695. // check for valid enum values
  1696. // [csv ssv tsv pipes]
  1697. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) {
  1698. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8)
  1699. errors = append(errors, compiler.NewError(context, message))
  1700. }
  1701. }
  1702. // Any default = 9;
  1703. v9 := compiler.MapValueForKey(m, "default")
  1704. if v9 != nil {
  1705. var err error
  1706. x.Default, err = NewAny(v9, compiler.NewContext("default", context))
  1707. if err != nil {
  1708. errors = append(errors, err)
  1709. }
  1710. }
  1711. // float maximum = 10;
  1712. v10 := compiler.MapValueForKey(m, "maximum")
  1713. if v10 != nil {
  1714. switch v10 := v10.(type) {
  1715. case float64:
  1716. x.Maximum = v10
  1717. case float32:
  1718. x.Maximum = float64(v10)
  1719. case uint64:
  1720. x.Maximum = float64(v10)
  1721. case uint32:
  1722. x.Maximum = float64(v10)
  1723. case int64:
  1724. x.Maximum = float64(v10)
  1725. case int32:
  1726. x.Maximum = float64(v10)
  1727. case int:
  1728. x.Maximum = float64(v10)
  1729. default:
  1730. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10)
  1731. errors = append(errors, compiler.NewError(context, message))
  1732. }
  1733. }
  1734. // bool exclusive_maximum = 11;
  1735. v11 := compiler.MapValueForKey(m, "exclusiveMaximum")
  1736. if v11 != nil {
  1737. x.ExclusiveMaximum, ok = v11.(bool)
  1738. if !ok {
  1739. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11)
  1740. errors = append(errors, compiler.NewError(context, message))
  1741. }
  1742. }
  1743. // float minimum = 12;
  1744. v12 := compiler.MapValueForKey(m, "minimum")
  1745. if v12 != nil {
  1746. switch v12 := v12.(type) {
  1747. case float64:
  1748. x.Minimum = v12
  1749. case float32:
  1750. x.Minimum = float64(v12)
  1751. case uint64:
  1752. x.Minimum = float64(v12)
  1753. case uint32:
  1754. x.Minimum = float64(v12)
  1755. case int64:
  1756. x.Minimum = float64(v12)
  1757. case int32:
  1758. x.Minimum = float64(v12)
  1759. case int:
  1760. x.Minimum = float64(v12)
  1761. default:
  1762. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12)
  1763. errors = append(errors, compiler.NewError(context, message))
  1764. }
  1765. }
  1766. // bool exclusive_minimum = 13;
  1767. v13 := compiler.MapValueForKey(m, "exclusiveMinimum")
  1768. if v13 != nil {
  1769. x.ExclusiveMinimum, ok = v13.(bool)
  1770. if !ok {
  1771. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13)
  1772. errors = append(errors, compiler.NewError(context, message))
  1773. }
  1774. }
  1775. // int64 max_length = 14;
  1776. v14 := compiler.MapValueForKey(m, "maxLength")
  1777. if v14 != nil {
  1778. t, ok := v14.(int)
  1779. if ok {
  1780. x.MaxLength = int64(t)
  1781. } else {
  1782. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14)
  1783. errors = append(errors, compiler.NewError(context, message))
  1784. }
  1785. }
  1786. // int64 min_length = 15;
  1787. v15 := compiler.MapValueForKey(m, "minLength")
  1788. if v15 != nil {
  1789. t, ok := v15.(int)
  1790. if ok {
  1791. x.MinLength = int64(t)
  1792. } else {
  1793. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15)
  1794. errors = append(errors, compiler.NewError(context, message))
  1795. }
  1796. }
  1797. // string pattern = 16;
  1798. v16 := compiler.MapValueForKey(m, "pattern")
  1799. if v16 != nil {
  1800. x.Pattern, ok = v16.(string)
  1801. if !ok {
  1802. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16)
  1803. errors = append(errors, compiler.NewError(context, message))
  1804. }
  1805. }
  1806. // int64 max_items = 17;
  1807. v17 := compiler.MapValueForKey(m, "maxItems")
  1808. if v17 != nil {
  1809. t, ok := v17.(int)
  1810. if ok {
  1811. x.MaxItems = int64(t)
  1812. } else {
  1813. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17)
  1814. errors = append(errors, compiler.NewError(context, message))
  1815. }
  1816. }
  1817. // int64 min_items = 18;
  1818. v18 := compiler.MapValueForKey(m, "minItems")
  1819. if v18 != nil {
  1820. t, ok := v18.(int)
  1821. if ok {
  1822. x.MinItems = int64(t)
  1823. } else {
  1824. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18)
  1825. errors = append(errors, compiler.NewError(context, message))
  1826. }
  1827. }
  1828. // bool unique_items = 19;
  1829. v19 := compiler.MapValueForKey(m, "uniqueItems")
  1830. if v19 != nil {
  1831. x.UniqueItems, ok = v19.(bool)
  1832. if !ok {
  1833. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19)
  1834. errors = append(errors, compiler.NewError(context, message))
  1835. }
  1836. }
  1837. // repeated Any enum = 20;
  1838. v20 := compiler.MapValueForKey(m, "enum")
  1839. if v20 != nil {
  1840. // repeated Any
  1841. x.Enum = make([]*Any, 0)
  1842. a, ok := v20.([]interface{})
  1843. if ok {
  1844. for _, item := range a {
  1845. y, err := NewAny(item, compiler.NewContext("enum", context))
  1846. if err != nil {
  1847. errors = append(errors, err)
  1848. }
  1849. x.Enum = append(x.Enum, y)
  1850. }
  1851. }
  1852. }
  1853. // float multiple_of = 21;
  1854. v21 := compiler.MapValueForKey(m, "multipleOf")
  1855. if v21 != nil {
  1856. switch v21 := v21.(type) {
  1857. case float64:
  1858. x.MultipleOf = v21
  1859. case float32:
  1860. x.MultipleOf = float64(v21)
  1861. case uint64:
  1862. x.MultipleOf = float64(v21)
  1863. case uint32:
  1864. x.MultipleOf = float64(v21)
  1865. case int64:
  1866. x.MultipleOf = float64(v21)
  1867. case int32:
  1868. x.MultipleOf = float64(v21)
  1869. case int:
  1870. x.MultipleOf = float64(v21)
  1871. default:
  1872. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21)
  1873. errors = append(errors, compiler.NewError(context, message))
  1874. }
  1875. }
  1876. // repeated NamedAny vendor_extension = 22;
  1877. // MAP: Any ^x-
  1878. x.VendorExtension = make([]*NamedAny, 0)
  1879. for _, item := range m {
  1880. k, ok := compiler.StringValue(item.Key)
  1881. if ok {
  1882. v := item.Value
  1883. if strings.HasPrefix(k, "x-") {
  1884. pair := &NamedAny{}
  1885. pair.Name = k
  1886. result := &Any{}
  1887. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  1888. if handled {
  1889. if err != nil {
  1890. errors = append(errors, err)
  1891. } else {
  1892. bytes, _ := yaml.Marshal(v)
  1893. result.Yaml = string(bytes)
  1894. result.Value = resultFromExt
  1895. pair.Value = result
  1896. }
  1897. } else {
  1898. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  1899. if err != nil {
  1900. errors = append(errors, err)
  1901. }
  1902. }
  1903. x.VendorExtension = append(x.VendorExtension, pair)
  1904. }
  1905. }
  1906. }
  1907. }
  1908. return x, compiler.NewErrorGroupOrNil(errors)
  1909. }
  1910. // NewHeaders creates an object of type Headers if possible, returning an error if not.
  1911. func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) {
  1912. errors := make([]error, 0)
  1913. x := &Headers{}
  1914. m, ok := compiler.UnpackMap(in)
  1915. if !ok {
  1916. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  1917. errors = append(errors, compiler.NewError(context, message))
  1918. } else {
  1919. // repeated NamedHeader additional_properties = 1;
  1920. // MAP: Header
  1921. x.AdditionalProperties = make([]*NamedHeader, 0)
  1922. for _, item := range m {
  1923. k, ok := compiler.StringValue(item.Key)
  1924. if ok {
  1925. v := item.Value
  1926. pair := &NamedHeader{}
  1927. pair.Name = k
  1928. var err error
  1929. pair.Value, err = NewHeader(v, compiler.NewContext(k, context))
  1930. if err != nil {
  1931. errors = append(errors, err)
  1932. }
  1933. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  1934. }
  1935. }
  1936. }
  1937. return x, compiler.NewErrorGroupOrNil(errors)
  1938. }
  1939. // NewInfo creates an object of type Info if possible, returning an error if not.
  1940. func NewInfo(in interface{}, context *compiler.Context) (*Info, error) {
  1941. errors := make([]error, 0)
  1942. x := &Info{}
  1943. m, ok := compiler.UnpackMap(in)
  1944. if !ok {
  1945. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  1946. errors = append(errors, compiler.NewError(context, message))
  1947. } else {
  1948. requiredKeys := []string{"title", "version"}
  1949. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  1950. if len(missingKeys) > 0 {
  1951. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  1952. errors = append(errors, compiler.NewError(context, message))
  1953. }
  1954. allowedKeys := []string{"contact", "description", "license", "termsOfService", "title", "version"}
  1955. allowedPatterns := []*regexp.Regexp{pattern0}
  1956. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  1957. if len(invalidKeys) > 0 {
  1958. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  1959. errors = append(errors, compiler.NewError(context, message))
  1960. }
  1961. // string title = 1;
  1962. v1 := compiler.MapValueForKey(m, "title")
  1963. if v1 != nil {
  1964. x.Title, ok = v1.(string)
  1965. if !ok {
  1966. message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1)
  1967. errors = append(errors, compiler.NewError(context, message))
  1968. }
  1969. }
  1970. // string version = 2;
  1971. v2 := compiler.MapValueForKey(m, "version")
  1972. if v2 != nil {
  1973. x.Version, ok = v2.(string)
  1974. if !ok {
  1975. message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v2, v2)
  1976. errors = append(errors, compiler.NewError(context, message))
  1977. }
  1978. }
  1979. // string description = 3;
  1980. v3 := compiler.MapValueForKey(m, "description")
  1981. if v3 != nil {
  1982. x.Description, ok = v3.(string)
  1983. if !ok {
  1984. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  1985. errors = append(errors, compiler.NewError(context, message))
  1986. }
  1987. }
  1988. // string terms_of_service = 4;
  1989. v4 := compiler.MapValueForKey(m, "termsOfService")
  1990. if v4 != nil {
  1991. x.TermsOfService, ok = v4.(string)
  1992. if !ok {
  1993. message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v4, v4)
  1994. errors = append(errors, compiler.NewError(context, message))
  1995. }
  1996. }
  1997. // Contact contact = 5;
  1998. v5 := compiler.MapValueForKey(m, "contact")
  1999. if v5 != nil {
  2000. var err error
  2001. x.Contact, err = NewContact(v5, compiler.NewContext("contact", context))
  2002. if err != nil {
  2003. errors = append(errors, err)
  2004. }
  2005. }
  2006. // License license = 6;
  2007. v6 := compiler.MapValueForKey(m, "license")
  2008. if v6 != nil {
  2009. var err error
  2010. x.License, err = NewLicense(v6, compiler.NewContext("license", context))
  2011. if err != nil {
  2012. errors = append(errors, err)
  2013. }
  2014. }
  2015. // repeated NamedAny vendor_extension = 7;
  2016. // MAP: Any ^x-
  2017. x.VendorExtension = make([]*NamedAny, 0)
  2018. for _, item := range m {
  2019. k, ok := compiler.StringValue(item.Key)
  2020. if ok {
  2021. v := item.Value
  2022. if strings.HasPrefix(k, "x-") {
  2023. pair := &NamedAny{}
  2024. pair.Name = k
  2025. result := &Any{}
  2026. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  2027. if handled {
  2028. if err != nil {
  2029. errors = append(errors, err)
  2030. } else {
  2031. bytes, _ := yaml.Marshal(v)
  2032. result.Yaml = string(bytes)
  2033. result.Value = resultFromExt
  2034. pair.Value = result
  2035. }
  2036. } else {
  2037. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  2038. if err != nil {
  2039. errors = append(errors, err)
  2040. }
  2041. }
  2042. x.VendorExtension = append(x.VendorExtension, pair)
  2043. }
  2044. }
  2045. }
  2046. }
  2047. return x, compiler.NewErrorGroupOrNil(errors)
  2048. }
  2049. // NewItemsItem creates an object of type ItemsItem if possible, returning an error if not.
  2050. func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) {
  2051. errors := make([]error, 0)
  2052. x := &ItemsItem{}
  2053. m, ok := compiler.UnpackMap(in)
  2054. if !ok {
  2055. message := fmt.Sprintf("has unexpected value for item array: %+v (%T)", in, in)
  2056. errors = append(errors, compiler.NewError(context, message))
  2057. } else {
  2058. x.Schema = make([]*Schema, 0)
  2059. y, err := NewSchema(m, compiler.NewContext("<array>", context))
  2060. if err != nil {
  2061. return nil, err
  2062. }
  2063. x.Schema = append(x.Schema, y)
  2064. }
  2065. return x, compiler.NewErrorGroupOrNil(errors)
  2066. }
  2067. // NewJsonReference creates an object of type JsonReference if possible, returning an error if not.
  2068. func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference, error) {
  2069. errors := make([]error, 0)
  2070. x := &JsonReference{}
  2071. m, ok := compiler.UnpackMap(in)
  2072. if !ok {
  2073. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2074. errors = append(errors, compiler.NewError(context, message))
  2075. } else {
  2076. requiredKeys := []string{"$ref"}
  2077. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2078. if len(missingKeys) > 0 {
  2079. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2080. errors = append(errors, compiler.NewError(context, message))
  2081. }
  2082. allowedKeys := []string{"$ref", "description"}
  2083. var allowedPatterns []*regexp.Regexp
  2084. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2085. if len(invalidKeys) > 0 {
  2086. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2087. errors = append(errors, compiler.NewError(context, message))
  2088. }
  2089. // string _ref = 1;
  2090. v1 := compiler.MapValueForKey(m, "$ref")
  2091. if v1 != nil {
  2092. x.XRef, ok = v1.(string)
  2093. if !ok {
  2094. message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1)
  2095. errors = append(errors, compiler.NewError(context, message))
  2096. }
  2097. }
  2098. // string description = 2;
  2099. v2 := compiler.MapValueForKey(m, "description")
  2100. if v2 != nil {
  2101. x.Description, ok = v2.(string)
  2102. if !ok {
  2103. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
  2104. errors = append(errors, compiler.NewError(context, message))
  2105. }
  2106. }
  2107. }
  2108. return x, compiler.NewErrorGroupOrNil(errors)
  2109. }
  2110. // NewLicense creates an object of type License if possible, returning an error if not.
  2111. func NewLicense(in interface{}, context *compiler.Context) (*License, error) {
  2112. errors := make([]error, 0)
  2113. x := &License{}
  2114. m, ok := compiler.UnpackMap(in)
  2115. if !ok {
  2116. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2117. errors = append(errors, compiler.NewError(context, message))
  2118. } else {
  2119. requiredKeys := []string{"name"}
  2120. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2121. if len(missingKeys) > 0 {
  2122. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2123. errors = append(errors, compiler.NewError(context, message))
  2124. }
  2125. allowedKeys := []string{"name", "url"}
  2126. allowedPatterns := []*regexp.Regexp{pattern0}
  2127. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2128. if len(invalidKeys) > 0 {
  2129. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2130. errors = append(errors, compiler.NewError(context, message))
  2131. }
  2132. // string name = 1;
  2133. v1 := compiler.MapValueForKey(m, "name")
  2134. if v1 != nil {
  2135. x.Name, ok = v1.(string)
  2136. if !ok {
  2137. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2138. errors = append(errors, compiler.NewError(context, message))
  2139. }
  2140. }
  2141. // string url = 2;
  2142. v2 := compiler.MapValueForKey(m, "url")
  2143. if v2 != nil {
  2144. x.Url, ok = v2.(string)
  2145. if !ok {
  2146. message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
  2147. errors = append(errors, compiler.NewError(context, message))
  2148. }
  2149. }
  2150. // repeated NamedAny vendor_extension = 3;
  2151. // MAP: Any ^x-
  2152. x.VendorExtension = make([]*NamedAny, 0)
  2153. for _, item := range m {
  2154. k, ok := compiler.StringValue(item.Key)
  2155. if ok {
  2156. v := item.Value
  2157. if strings.HasPrefix(k, "x-") {
  2158. pair := &NamedAny{}
  2159. pair.Name = k
  2160. result := &Any{}
  2161. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  2162. if handled {
  2163. if err != nil {
  2164. errors = append(errors, err)
  2165. } else {
  2166. bytes, _ := yaml.Marshal(v)
  2167. result.Yaml = string(bytes)
  2168. result.Value = resultFromExt
  2169. pair.Value = result
  2170. }
  2171. } else {
  2172. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  2173. if err != nil {
  2174. errors = append(errors, err)
  2175. }
  2176. }
  2177. x.VendorExtension = append(x.VendorExtension, pair)
  2178. }
  2179. }
  2180. }
  2181. }
  2182. return x, compiler.NewErrorGroupOrNil(errors)
  2183. }
  2184. // NewNamedAny creates an object of type NamedAny if possible, returning an error if not.
  2185. func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) {
  2186. errors := make([]error, 0)
  2187. x := &NamedAny{}
  2188. m, ok := compiler.UnpackMap(in)
  2189. if !ok {
  2190. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2191. errors = append(errors, compiler.NewError(context, message))
  2192. } else {
  2193. allowedKeys := []string{"name", "value"}
  2194. var allowedPatterns []*regexp.Regexp
  2195. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2196. if len(invalidKeys) > 0 {
  2197. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2198. errors = append(errors, compiler.NewError(context, message))
  2199. }
  2200. // string name = 1;
  2201. v1 := compiler.MapValueForKey(m, "name")
  2202. if v1 != nil {
  2203. x.Name, ok = v1.(string)
  2204. if !ok {
  2205. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2206. errors = append(errors, compiler.NewError(context, message))
  2207. }
  2208. }
  2209. // Any value = 2;
  2210. v2 := compiler.MapValueForKey(m, "value")
  2211. if v2 != nil {
  2212. var err error
  2213. x.Value, err = NewAny(v2, compiler.NewContext("value", context))
  2214. if err != nil {
  2215. errors = append(errors, err)
  2216. }
  2217. }
  2218. }
  2219. return x, compiler.NewErrorGroupOrNil(errors)
  2220. }
  2221. // NewNamedHeader creates an object of type NamedHeader if possible, returning an error if not.
  2222. func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, error) {
  2223. errors := make([]error, 0)
  2224. x := &NamedHeader{}
  2225. m, ok := compiler.UnpackMap(in)
  2226. if !ok {
  2227. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2228. errors = append(errors, compiler.NewError(context, message))
  2229. } else {
  2230. allowedKeys := []string{"name", "value"}
  2231. var allowedPatterns []*regexp.Regexp
  2232. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2233. if len(invalidKeys) > 0 {
  2234. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2235. errors = append(errors, compiler.NewError(context, message))
  2236. }
  2237. // string name = 1;
  2238. v1 := compiler.MapValueForKey(m, "name")
  2239. if v1 != nil {
  2240. x.Name, ok = v1.(string)
  2241. if !ok {
  2242. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2243. errors = append(errors, compiler.NewError(context, message))
  2244. }
  2245. }
  2246. // Header value = 2;
  2247. v2 := compiler.MapValueForKey(m, "value")
  2248. if v2 != nil {
  2249. var err error
  2250. x.Value, err = NewHeader(v2, compiler.NewContext("value", context))
  2251. if err != nil {
  2252. errors = append(errors, err)
  2253. }
  2254. }
  2255. }
  2256. return x, compiler.NewErrorGroupOrNil(errors)
  2257. }
  2258. // NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not.
  2259. func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) {
  2260. errors := make([]error, 0)
  2261. x := &NamedParameter{}
  2262. m, ok := compiler.UnpackMap(in)
  2263. if !ok {
  2264. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2265. errors = append(errors, compiler.NewError(context, message))
  2266. } else {
  2267. allowedKeys := []string{"name", "value"}
  2268. var allowedPatterns []*regexp.Regexp
  2269. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2270. if len(invalidKeys) > 0 {
  2271. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2272. errors = append(errors, compiler.NewError(context, message))
  2273. }
  2274. // string name = 1;
  2275. v1 := compiler.MapValueForKey(m, "name")
  2276. if v1 != nil {
  2277. x.Name, ok = v1.(string)
  2278. if !ok {
  2279. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2280. errors = append(errors, compiler.NewError(context, message))
  2281. }
  2282. }
  2283. // Parameter value = 2;
  2284. v2 := compiler.MapValueForKey(m, "value")
  2285. if v2 != nil {
  2286. var err error
  2287. x.Value, err = NewParameter(v2, compiler.NewContext("value", context))
  2288. if err != nil {
  2289. errors = append(errors, err)
  2290. }
  2291. }
  2292. }
  2293. return x, compiler.NewErrorGroupOrNil(errors)
  2294. }
  2295. // NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not.
  2296. func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) {
  2297. errors := make([]error, 0)
  2298. x := &NamedPathItem{}
  2299. m, ok := compiler.UnpackMap(in)
  2300. if !ok {
  2301. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2302. errors = append(errors, compiler.NewError(context, message))
  2303. } else {
  2304. allowedKeys := []string{"name", "value"}
  2305. var allowedPatterns []*regexp.Regexp
  2306. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2307. if len(invalidKeys) > 0 {
  2308. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2309. errors = append(errors, compiler.NewError(context, message))
  2310. }
  2311. // string name = 1;
  2312. v1 := compiler.MapValueForKey(m, "name")
  2313. if v1 != nil {
  2314. x.Name, ok = v1.(string)
  2315. if !ok {
  2316. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2317. errors = append(errors, compiler.NewError(context, message))
  2318. }
  2319. }
  2320. // PathItem value = 2;
  2321. v2 := compiler.MapValueForKey(m, "value")
  2322. if v2 != nil {
  2323. var err error
  2324. x.Value, err = NewPathItem(v2, compiler.NewContext("value", context))
  2325. if err != nil {
  2326. errors = append(errors, err)
  2327. }
  2328. }
  2329. }
  2330. return x, compiler.NewErrorGroupOrNil(errors)
  2331. }
  2332. // NewNamedResponse creates an object of type NamedResponse if possible, returning an error if not.
  2333. func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse, error) {
  2334. errors := make([]error, 0)
  2335. x := &NamedResponse{}
  2336. m, ok := compiler.UnpackMap(in)
  2337. if !ok {
  2338. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2339. errors = append(errors, compiler.NewError(context, message))
  2340. } else {
  2341. allowedKeys := []string{"name", "value"}
  2342. var allowedPatterns []*regexp.Regexp
  2343. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2344. if len(invalidKeys) > 0 {
  2345. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2346. errors = append(errors, compiler.NewError(context, message))
  2347. }
  2348. // string name = 1;
  2349. v1 := compiler.MapValueForKey(m, "name")
  2350. if v1 != nil {
  2351. x.Name, ok = v1.(string)
  2352. if !ok {
  2353. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2354. errors = append(errors, compiler.NewError(context, message))
  2355. }
  2356. }
  2357. // Response value = 2;
  2358. v2 := compiler.MapValueForKey(m, "value")
  2359. if v2 != nil {
  2360. var err error
  2361. x.Value, err = NewResponse(v2, compiler.NewContext("value", context))
  2362. if err != nil {
  2363. errors = append(errors, err)
  2364. }
  2365. }
  2366. }
  2367. return x, compiler.NewErrorGroupOrNil(errors)
  2368. }
  2369. // NewNamedResponseValue creates an object of type NamedResponseValue if possible, returning an error if not.
  2370. func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedResponseValue, error) {
  2371. errors := make([]error, 0)
  2372. x := &NamedResponseValue{}
  2373. m, ok := compiler.UnpackMap(in)
  2374. if !ok {
  2375. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2376. errors = append(errors, compiler.NewError(context, message))
  2377. } else {
  2378. allowedKeys := []string{"name", "value"}
  2379. var allowedPatterns []*regexp.Regexp
  2380. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2381. if len(invalidKeys) > 0 {
  2382. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2383. errors = append(errors, compiler.NewError(context, message))
  2384. }
  2385. // string name = 1;
  2386. v1 := compiler.MapValueForKey(m, "name")
  2387. if v1 != nil {
  2388. x.Name, ok = v1.(string)
  2389. if !ok {
  2390. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2391. errors = append(errors, compiler.NewError(context, message))
  2392. }
  2393. }
  2394. // ResponseValue value = 2;
  2395. v2 := compiler.MapValueForKey(m, "value")
  2396. if v2 != nil {
  2397. var err error
  2398. x.Value, err = NewResponseValue(v2, compiler.NewContext("value", context))
  2399. if err != nil {
  2400. errors = append(errors, err)
  2401. }
  2402. }
  2403. }
  2404. return x, compiler.NewErrorGroupOrNil(errors)
  2405. }
  2406. // NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not.
  2407. func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) {
  2408. errors := make([]error, 0)
  2409. x := &NamedSchema{}
  2410. m, ok := compiler.UnpackMap(in)
  2411. if !ok {
  2412. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2413. errors = append(errors, compiler.NewError(context, message))
  2414. } else {
  2415. allowedKeys := []string{"name", "value"}
  2416. var allowedPatterns []*regexp.Regexp
  2417. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2418. if len(invalidKeys) > 0 {
  2419. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2420. errors = append(errors, compiler.NewError(context, message))
  2421. }
  2422. // string name = 1;
  2423. v1 := compiler.MapValueForKey(m, "name")
  2424. if v1 != nil {
  2425. x.Name, ok = v1.(string)
  2426. if !ok {
  2427. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2428. errors = append(errors, compiler.NewError(context, message))
  2429. }
  2430. }
  2431. // Schema value = 2;
  2432. v2 := compiler.MapValueForKey(m, "value")
  2433. if v2 != nil {
  2434. var err error
  2435. x.Value, err = NewSchema(v2, compiler.NewContext("value", context))
  2436. if err != nil {
  2437. errors = append(errors, err)
  2438. }
  2439. }
  2440. }
  2441. return x, compiler.NewErrorGroupOrNil(errors)
  2442. }
  2443. // NewNamedSecurityDefinitionsItem creates an object of type NamedSecurityDefinitionsItem if possible, returning an error if not.
  2444. func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) {
  2445. errors := make([]error, 0)
  2446. x := &NamedSecurityDefinitionsItem{}
  2447. m, ok := compiler.UnpackMap(in)
  2448. if !ok {
  2449. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2450. errors = append(errors, compiler.NewError(context, message))
  2451. } else {
  2452. allowedKeys := []string{"name", "value"}
  2453. var allowedPatterns []*regexp.Regexp
  2454. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2455. if len(invalidKeys) > 0 {
  2456. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2457. errors = append(errors, compiler.NewError(context, message))
  2458. }
  2459. // string name = 1;
  2460. v1 := compiler.MapValueForKey(m, "name")
  2461. if v1 != nil {
  2462. x.Name, ok = v1.(string)
  2463. if !ok {
  2464. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2465. errors = append(errors, compiler.NewError(context, message))
  2466. }
  2467. }
  2468. // SecurityDefinitionsItem value = 2;
  2469. v2 := compiler.MapValueForKey(m, "value")
  2470. if v2 != nil {
  2471. var err error
  2472. x.Value, err = NewSecurityDefinitionsItem(v2, compiler.NewContext("value", context))
  2473. if err != nil {
  2474. errors = append(errors, err)
  2475. }
  2476. }
  2477. }
  2478. return x, compiler.NewErrorGroupOrNil(errors)
  2479. }
  2480. // NewNamedString creates an object of type NamedString if possible, returning an error if not.
  2481. func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, error) {
  2482. errors := make([]error, 0)
  2483. x := &NamedString{}
  2484. m, ok := compiler.UnpackMap(in)
  2485. if !ok {
  2486. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2487. errors = append(errors, compiler.NewError(context, message))
  2488. } else {
  2489. allowedKeys := []string{"name", "value"}
  2490. var allowedPatterns []*regexp.Regexp
  2491. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2492. if len(invalidKeys) > 0 {
  2493. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2494. errors = append(errors, compiler.NewError(context, message))
  2495. }
  2496. // string name = 1;
  2497. v1 := compiler.MapValueForKey(m, "name")
  2498. if v1 != nil {
  2499. x.Name, ok = v1.(string)
  2500. if !ok {
  2501. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2502. errors = append(errors, compiler.NewError(context, message))
  2503. }
  2504. }
  2505. // string value = 2;
  2506. v2 := compiler.MapValueForKey(m, "value")
  2507. if v2 != nil {
  2508. x.Value, ok = v2.(string)
  2509. if !ok {
  2510. message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2)
  2511. errors = append(errors, compiler.NewError(context, message))
  2512. }
  2513. }
  2514. }
  2515. return x, compiler.NewErrorGroupOrNil(errors)
  2516. }
  2517. // NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not.
  2518. func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStringArray, error) {
  2519. errors := make([]error, 0)
  2520. x := &NamedStringArray{}
  2521. m, ok := compiler.UnpackMap(in)
  2522. if !ok {
  2523. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2524. errors = append(errors, compiler.NewError(context, message))
  2525. } else {
  2526. allowedKeys := []string{"name", "value"}
  2527. var allowedPatterns []*regexp.Regexp
  2528. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2529. if len(invalidKeys) > 0 {
  2530. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2531. errors = append(errors, compiler.NewError(context, message))
  2532. }
  2533. // string name = 1;
  2534. v1 := compiler.MapValueForKey(m, "name")
  2535. if v1 != nil {
  2536. x.Name, ok = v1.(string)
  2537. if !ok {
  2538. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  2539. errors = append(errors, compiler.NewError(context, message))
  2540. }
  2541. }
  2542. // StringArray value = 2;
  2543. v2 := compiler.MapValueForKey(m, "value")
  2544. if v2 != nil {
  2545. var err error
  2546. x.Value, err = NewStringArray(v2, compiler.NewContext("value", context))
  2547. if err != nil {
  2548. errors = append(errors, err)
  2549. }
  2550. }
  2551. }
  2552. return x, compiler.NewErrorGroupOrNil(errors)
  2553. }
  2554. // NewNonBodyParameter creates an object of type NonBodyParameter if possible, returning an error if not.
  2555. func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyParameter, error) {
  2556. errors := make([]error, 0)
  2557. x := &NonBodyParameter{}
  2558. matched := false
  2559. m, ok := compiler.UnpackMap(in)
  2560. if !ok {
  2561. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2562. errors = append(errors, compiler.NewError(context, message))
  2563. } else {
  2564. requiredKeys := []string{"in", "name", "type"}
  2565. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2566. if len(missingKeys) > 0 {
  2567. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2568. errors = append(errors, compiler.NewError(context, message))
  2569. }
  2570. // HeaderParameterSubSchema header_parameter_sub_schema = 1;
  2571. {
  2572. // errors might be ok here, they mean we just don't have the right subtype
  2573. t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context))
  2574. if matchingError == nil {
  2575. x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t}
  2576. matched = true
  2577. } else {
  2578. errors = append(errors, matchingError)
  2579. }
  2580. }
  2581. // FormDataParameterSubSchema form_data_parameter_sub_schema = 2;
  2582. {
  2583. // errors might be ok here, they mean we just don't have the right subtype
  2584. t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context))
  2585. if matchingError == nil {
  2586. x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t}
  2587. matched = true
  2588. } else {
  2589. errors = append(errors, matchingError)
  2590. }
  2591. }
  2592. // QueryParameterSubSchema query_parameter_sub_schema = 3;
  2593. {
  2594. // errors might be ok here, they mean we just don't have the right subtype
  2595. t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context))
  2596. if matchingError == nil {
  2597. x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t}
  2598. matched = true
  2599. } else {
  2600. errors = append(errors, matchingError)
  2601. }
  2602. }
  2603. // PathParameterSubSchema path_parameter_sub_schema = 4;
  2604. {
  2605. // errors might be ok here, they mean we just don't have the right subtype
  2606. t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context))
  2607. if matchingError == nil {
  2608. x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t}
  2609. matched = true
  2610. } else {
  2611. errors = append(errors, matchingError)
  2612. }
  2613. }
  2614. }
  2615. if matched {
  2616. // since the oneof matched one of its possibilities, discard any matching errors
  2617. errors = make([]error, 0)
  2618. }
  2619. return x, compiler.NewErrorGroupOrNil(errors)
  2620. }
  2621. // NewOauth2AccessCodeSecurity creates an object of type Oauth2AccessCodeSecurity if possible, returning an error if not.
  2622. func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) {
  2623. errors := make([]error, 0)
  2624. x := &Oauth2AccessCodeSecurity{}
  2625. m, ok := compiler.UnpackMap(in)
  2626. if !ok {
  2627. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2628. errors = append(errors, compiler.NewError(context, message))
  2629. } else {
  2630. requiredKeys := []string{"authorizationUrl", "flow", "tokenUrl", "type"}
  2631. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2632. if len(missingKeys) > 0 {
  2633. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2634. errors = append(errors, compiler.NewError(context, message))
  2635. }
  2636. allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "tokenUrl", "type"}
  2637. allowedPatterns := []*regexp.Regexp{pattern0}
  2638. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2639. if len(invalidKeys) > 0 {
  2640. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2641. errors = append(errors, compiler.NewError(context, message))
  2642. }
  2643. // string type = 1;
  2644. v1 := compiler.MapValueForKey(m, "type")
  2645. if v1 != nil {
  2646. x.Type, ok = v1.(string)
  2647. if !ok {
  2648. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2649. errors = append(errors, compiler.NewError(context, message))
  2650. }
  2651. // check for valid enum values
  2652. // [oauth2]
  2653. if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) {
  2654. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2655. errors = append(errors, compiler.NewError(context, message))
  2656. }
  2657. }
  2658. // string flow = 2;
  2659. v2 := compiler.MapValueForKey(m, "flow")
  2660. if v2 != nil {
  2661. x.Flow, ok = v2.(string)
  2662. if !ok {
  2663. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2664. errors = append(errors, compiler.NewError(context, message))
  2665. }
  2666. // check for valid enum values
  2667. // [accessCode]
  2668. if ok && !compiler.StringArrayContainsValue([]string{"accessCode"}, x.Flow) {
  2669. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2670. errors = append(errors, compiler.NewError(context, message))
  2671. }
  2672. }
  2673. // Oauth2Scopes scopes = 3;
  2674. v3 := compiler.MapValueForKey(m, "scopes")
  2675. if v3 != nil {
  2676. var err error
  2677. x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context))
  2678. if err != nil {
  2679. errors = append(errors, err)
  2680. }
  2681. }
  2682. // string authorization_url = 4;
  2683. v4 := compiler.MapValueForKey(m, "authorizationUrl")
  2684. if v4 != nil {
  2685. x.AuthorizationUrl, ok = v4.(string)
  2686. if !ok {
  2687. message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4)
  2688. errors = append(errors, compiler.NewError(context, message))
  2689. }
  2690. }
  2691. // string token_url = 5;
  2692. v5 := compiler.MapValueForKey(m, "tokenUrl")
  2693. if v5 != nil {
  2694. x.TokenUrl, ok = v5.(string)
  2695. if !ok {
  2696. message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v5, v5)
  2697. errors = append(errors, compiler.NewError(context, message))
  2698. }
  2699. }
  2700. // string description = 6;
  2701. v6 := compiler.MapValueForKey(m, "description")
  2702. if v6 != nil {
  2703. x.Description, ok = v6.(string)
  2704. if !ok {
  2705. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v6, v6)
  2706. errors = append(errors, compiler.NewError(context, message))
  2707. }
  2708. }
  2709. // repeated NamedAny vendor_extension = 7;
  2710. // MAP: Any ^x-
  2711. x.VendorExtension = make([]*NamedAny, 0)
  2712. for _, item := range m {
  2713. k, ok := compiler.StringValue(item.Key)
  2714. if ok {
  2715. v := item.Value
  2716. if strings.HasPrefix(k, "x-") {
  2717. pair := &NamedAny{}
  2718. pair.Name = k
  2719. result := &Any{}
  2720. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  2721. if handled {
  2722. if err != nil {
  2723. errors = append(errors, err)
  2724. } else {
  2725. bytes, _ := yaml.Marshal(v)
  2726. result.Yaml = string(bytes)
  2727. result.Value = resultFromExt
  2728. pair.Value = result
  2729. }
  2730. } else {
  2731. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  2732. if err != nil {
  2733. errors = append(errors, err)
  2734. }
  2735. }
  2736. x.VendorExtension = append(x.VendorExtension, pair)
  2737. }
  2738. }
  2739. }
  2740. }
  2741. return x, compiler.NewErrorGroupOrNil(errors)
  2742. }
  2743. // NewOauth2ApplicationSecurity creates an object of type Oauth2ApplicationSecurity if possible, returning an error if not.
  2744. func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*Oauth2ApplicationSecurity, error) {
  2745. errors := make([]error, 0)
  2746. x := &Oauth2ApplicationSecurity{}
  2747. m, ok := compiler.UnpackMap(in)
  2748. if !ok {
  2749. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2750. errors = append(errors, compiler.NewError(context, message))
  2751. } else {
  2752. requiredKeys := []string{"flow", "tokenUrl", "type"}
  2753. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2754. if len(missingKeys) > 0 {
  2755. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2756. errors = append(errors, compiler.NewError(context, message))
  2757. }
  2758. allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"}
  2759. allowedPatterns := []*regexp.Regexp{pattern0}
  2760. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2761. if len(invalidKeys) > 0 {
  2762. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2763. errors = append(errors, compiler.NewError(context, message))
  2764. }
  2765. // string type = 1;
  2766. v1 := compiler.MapValueForKey(m, "type")
  2767. if v1 != nil {
  2768. x.Type, ok = v1.(string)
  2769. if !ok {
  2770. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2771. errors = append(errors, compiler.NewError(context, message))
  2772. }
  2773. // check for valid enum values
  2774. // [oauth2]
  2775. if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) {
  2776. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2777. errors = append(errors, compiler.NewError(context, message))
  2778. }
  2779. }
  2780. // string flow = 2;
  2781. v2 := compiler.MapValueForKey(m, "flow")
  2782. if v2 != nil {
  2783. x.Flow, ok = v2.(string)
  2784. if !ok {
  2785. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2786. errors = append(errors, compiler.NewError(context, message))
  2787. }
  2788. // check for valid enum values
  2789. // [application]
  2790. if ok && !compiler.StringArrayContainsValue([]string{"application"}, x.Flow) {
  2791. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2792. errors = append(errors, compiler.NewError(context, message))
  2793. }
  2794. }
  2795. // Oauth2Scopes scopes = 3;
  2796. v3 := compiler.MapValueForKey(m, "scopes")
  2797. if v3 != nil {
  2798. var err error
  2799. x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context))
  2800. if err != nil {
  2801. errors = append(errors, err)
  2802. }
  2803. }
  2804. // string token_url = 4;
  2805. v4 := compiler.MapValueForKey(m, "tokenUrl")
  2806. if v4 != nil {
  2807. x.TokenUrl, ok = v4.(string)
  2808. if !ok {
  2809. message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4)
  2810. errors = append(errors, compiler.NewError(context, message))
  2811. }
  2812. }
  2813. // string description = 5;
  2814. v5 := compiler.MapValueForKey(m, "description")
  2815. if v5 != nil {
  2816. x.Description, ok = v5.(string)
  2817. if !ok {
  2818. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5)
  2819. errors = append(errors, compiler.NewError(context, message))
  2820. }
  2821. }
  2822. // repeated NamedAny vendor_extension = 6;
  2823. // MAP: Any ^x-
  2824. x.VendorExtension = make([]*NamedAny, 0)
  2825. for _, item := range m {
  2826. k, ok := compiler.StringValue(item.Key)
  2827. if ok {
  2828. v := item.Value
  2829. if strings.HasPrefix(k, "x-") {
  2830. pair := &NamedAny{}
  2831. pair.Name = k
  2832. result := &Any{}
  2833. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  2834. if handled {
  2835. if err != nil {
  2836. errors = append(errors, err)
  2837. } else {
  2838. bytes, _ := yaml.Marshal(v)
  2839. result.Yaml = string(bytes)
  2840. result.Value = resultFromExt
  2841. pair.Value = result
  2842. }
  2843. } else {
  2844. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  2845. if err != nil {
  2846. errors = append(errors, err)
  2847. }
  2848. }
  2849. x.VendorExtension = append(x.VendorExtension, pair)
  2850. }
  2851. }
  2852. }
  2853. }
  2854. return x, compiler.NewErrorGroupOrNil(errors)
  2855. }
  2856. // NewOauth2ImplicitSecurity creates an object of type Oauth2ImplicitSecurity if possible, returning an error if not.
  2857. func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oauth2ImplicitSecurity, error) {
  2858. errors := make([]error, 0)
  2859. x := &Oauth2ImplicitSecurity{}
  2860. m, ok := compiler.UnpackMap(in)
  2861. if !ok {
  2862. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2863. errors = append(errors, compiler.NewError(context, message))
  2864. } else {
  2865. requiredKeys := []string{"authorizationUrl", "flow", "type"}
  2866. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2867. if len(missingKeys) > 0 {
  2868. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2869. errors = append(errors, compiler.NewError(context, message))
  2870. }
  2871. allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "type"}
  2872. allowedPatterns := []*regexp.Regexp{pattern0}
  2873. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2874. if len(invalidKeys) > 0 {
  2875. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2876. errors = append(errors, compiler.NewError(context, message))
  2877. }
  2878. // string type = 1;
  2879. v1 := compiler.MapValueForKey(m, "type")
  2880. if v1 != nil {
  2881. x.Type, ok = v1.(string)
  2882. if !ok {
  2883. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2884. errors = append(errors, compiler.NewError(context, message))
  2885. }
  2886. // check for valid enum values
  2887. // [oauth2]
  2888. if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) {
  2889. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2890. errors = append(errors, compiler.NewError(context, message))
  2891. }
  2892. }
  2893. // string flow = 2;
  2894. v2 := compiler.MapValueForKey(m, "flow")
  2895. if v2 != nil {
  2896. x.Flow, ok = v2.(string)
  2897. if !ok {
  2898. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2899. errors = append(errors, compiler.NewError(context, message))
  2900. }
  2901. // check for valid enum values
  2902. // [implicit]
  2903. if ok && !compiler.StringArrayContainsValue([]string{"implicit"}, x.Flow) {
  2904. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  2905. errors = append(errors, compiler.NewError(context, message))
  2906. }
  2907. }
  2908. // Oauth2Scopes scopes = 3;
  2909. v3 := compiler.MapValueForKey(m, "scopes")
  2910. if v3 != nil {
  2911. var err error
  2912. x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context))
  2913. if err != nil {
  2914. errors = append(errors, err)
  2915. }
  2916. }
  2917. // string authorization_url = 4;
  2918. v4 := compiler.MapValueForKey(m, "authorizationUrl")
  2919. if v4 != nil {
  2920. x.AuthorizationUrl, ok = v4.(string)
  2921. if !ok {
  2922. message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4)
  2923. errors = append(errors, compiler.NewError(context, message))
  2924. }
  2925. }
  2926. // string description = 5;
  2927. v5 := compiler.MapValueForKey(m, "description")
  2928. if v5 != nil {
  2929. x.Description, ok = v5.(string)
  2930. if !ok {
  2931. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5)
  2932. errors = append(errors, compiler.NewError(context, message))
  2933. }
  2934. }
  2935. // repeated NamedAny vendor_extension = 6;
  2936. // MAP: Any ^x-
  2937. x.VendorExtension = make([]*NamedAny, 0)
  2938. for _, item := range m {
  2939. k, ok := compiler.StringValue(item.Key)
  2940. if ok {
  2941. v := item.Value
  2942. if strings.HasPrefix(k, "x-") {
  2943. pair := &NamedAny{}
  2944. pair.Name = k
  2945. result := &Any{}
  2946. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  2947. if handled {
  2948. if err != nil {
  2949. errors = append(errors, err)
  2950. } else {
  2951. bytes, _ := yaml.Marshal(v)
  2952. result.Yaml = string(bytes)
  2953. result.Value = resultFromExt
  2954. pair.Value = result
  2955. }
  2956. } else {
  2957. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  2958. if err != nil {
  2959. errors = append(errors, err)
  2960. }
  2961. }
  2962. x.VendorExtension = append(x.VendorExtension, pair)
  2963. }
  2964. }
  2965. }
  2966. }
  2967. return x, compiler.NewErrorGroupOrNil(errors)
  2968. }
  2969. // NewOauth2PasswordSecurity creates an object of type Oauth2PasswordSecurity if possible, returning an error if not.
  2970. func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oauth2PasswordSecurity, error) {
  2971. errors := make([]error, 0)
  2972. x := &Oauth2PasswordSecurity{}
  2973. m, ok := compiler.UnpackMap(in)
  2974. if !ok {
  2975. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  2976. errors = append(errors, compiler.NewError(context, message))
  2977. } else {
  2978. requiredKeys := []string{"flow", "tokenUrl", "type"}
  2979. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  2980. if len(missingKeys) > 0 {
  2981. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  2982. errors = append(errors, compiler.NewError(context, message))
  2983. }
  2984. allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"}
  2985. allowedPatterns := []*regexp.Regexp{pattern0}
  2986. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  2987. if len(invalidKeys) > 0 {
  2988. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  2989. errors = append(errors, compiler.NewError(context, message))
  2990. }
  2991. // string type = 1;
  2992. v1 := compiler.MapValueForKey(m, "type")
  2993. if v1 != nil {
  2994. x.Type, ok = v1.(string)
  2995. if !ok {
  2996. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  2997. errors = append(errors, compiler.NewError(context, message))
  2998. }
  2999. // check for valid enum values
  3000. // [oauth2]
  3001. if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) {
  3002. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  3003. errors = append(errors, compiler.NewError(context, message))
  3004. }
  3005. }
  3006. // string flow = 2;
  3007. v2 := compiler.MapValueForKey(m, "flow")
  3008. if v2 != nil {
  3009. x.Flow, ok = v2.(string)
  3010. if !ok {
  3011. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  3012. errors = append(errors, compiler.NewError(context, message))
  3013. }
  3014. // check for valid enum values
  3015. // [password]
  3016. if ok && !compiler.StringArrayContainsValue([]string{"password"}, x.Flow) {
  3017. message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2)
  3018. errors = append(errors, compiler.NewError(context, message))
  3019. }
  3020. }
  3021. // Oauth2Scopes scopes = 3;
  3022. v3 := compiler.MapValueForKey(m, "scopes")
  3023. if v3 != nil {
  3024. var err error
  3025. x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context))
  3026. if err != nil {
  3027. errors = append(errors, err)
  3028. }
  3029. }
  3030. // string token_url = 4;
  3031. v4 := compiler.MapValueForKey(m, "tokenUrl")
  3032. if v4 != nil {
  3033. x.TokenUrl, ok = v4.(string)
  3034. if !ok {
  3035. message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4)
  3036. errors = append(errors, compiler.NewError(context, message))
  3037. }
  3038. }
  3039. // string description = 5;
  3040. v5 := compiler.MapValueForKey(m, "description")
  3041. if v5 != nil {
  3042. x.Description, ok = v5.(string)
  3043. if !ok {
  3044. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5)
  3045. errors = append(errors, compiler.NewError(context, message))
  3046. }
  3047. }
  3048. // repeated NamedAny vendor_extension = 6;
  3049. // MAP: Any ^x-
  3050. x.VendorExtension = make([]*NamedAny, 0)
  3051. for _, item := range m {
  3052. k, ok := compiler.StringValue(item.Key)
  3053. if ok {
  3054. v := item.Value
  3055. if strings.HasPrefix(k, "x-") {
  3056. pair := &NamedAny{}
  3057. pair.Name = k
  3058. result := &Any{}
  3059. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  3060. if handled {
  3061. if err != nil {
  3062. errors = append(errors, err)
  3063. } else {
  3064. bytes, _ := yaml.Marshal(v)
  3065. result.Yaml = string(bytes)
  3066. result.Value = resultFromExt
  3067. pair.Value = result
  3068. }
  3069. } else {
  3070. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  3071. if err != nil {
  3072. errors = append(errors, err)
  3073. }
  3074. }
  3075. x.VendorExtension = append(x.VendorExtension, pair)
  3076. }
  3077. }
  3078. }
  3079. }
  3080. return x, compiler.NewErrorGroupOrNil(errors)
  3081. }
  3082. // NewOauth2Scopes creates an object of type Oauth2Scopes if possible, returning an error if not.
  3083. func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, error) {
  3084. errors := make([]error, 0)
  3085. x := &Oauth2Scopes{}
  3086. m, ok := compiler.UnpackMap(in)
  3087. if !ok {
  3088. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3089. errors = append(errors, compiler.NewError(context, message))
  3090. } else {
  3091. // repeated NamedString additional_properties = 1;
  3092. // MAP: string
  3093. x.AdditionalProperties = make([]*NamedString, 0)
  3094. for _, item := range m {
  3095. k, ok := compiler.StringValue(item.Key)
  3096. if ok {
  3097. v := item.Value
  3098. pair := &NamedString{}
  3099. pair.Name = k
  3100. pair.Value = v.(string)
  3101. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  3102. }
  3103. }
  3104. }
  3105. return x, compiler.NewErrorGroupOrNil(errors)
  3106. }
  3107. // NewOperation creates an object of type Operation if possible, returning an error if not.
  3108. func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) {
  3109. errors := make([]error, 0)
  3110. x := &Operation{}
  3111. m, ok := compiler.UnpackMap(in)
  3112. if !ok {
  3113. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3114. errors = append(errors, compiler.NewError(context, message))
  3115. } else {
  3116. requiredKeys := []string{"responses"}
  3117. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  3118. if len(missingKeys) > 0 {
  3119. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  3120. errors = append(errors, compiler.NewError(context, message))
  3121. }
  3122. allowedKeys := []string{"consumes", "deprecated", "description", "externalDocs", "operationId", "parameters", "produces", "responses", "schemes", "security", "summary", "tags"}
  3123. allowedPatterns := []*regexp.Regexp{pattern0}
  3124. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  3125. if len(invalidKeys) > 0 {
  3126. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  3127. errors = append(errors, compiler.NewError(context, message))
  3128. }
  3129. // repeated string tags = 1;
  3130. v1 := compiler.MapValueForKey(m, "tags")
  3131. if v1 != nil {
  3132. v, ok := v1.([]interface{})
  3133. if ok {
  3134. x.Tags = compiler.ConvertInterfaceArrayToStringArray(v)
  3135. } else {
  3136. message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1)
  3137. errors = append(errors, compiler.NewError(context, message))
  3138. }
  3139. }
  3140. // string summary = 2;
  3141. v2 := compiler.MapValueForKey(m, "summary")
  3142. if v2 != nil {
  3143. x.Summary, ok = v2.(string)
  3144. if !ok {
  3145. message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2)
  3146. errors = append(errors, compiler.NewError(context, message))
  3147. }
  3148. }
  3149. // string description = 3;
  3150. v3 := compiler.MapValueForKey(m, "description")
  3151. if v3 != nil {
  3152. x.Description, ok = v3.(string)
  3153. if !ok {
  3154. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  3155. errors = append(errors, compiler.NewError(context, message))
  3156. }
  3157. }
  3158. // ExternalDocs external_docs = 4;
  3159. v4 := compiler.MapValueForKey(m, "externalDocs")
  3160. if v4 != nil {
  3161. var err error
  3162. x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", context))
  3163. if err != nil {
  3164. errors = append(errors, err)
  3165. }
  3166. }
  3167. // string operation_id = 5;
  3168. v5 := compiler.MapValueForKey(m, "operationId")
  3169. if v5 != nil {
  3170. x.OperationId, ok = v5.(string)
  3171. if !ok {
  3172. message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5)
  3173. errors = append(errors, compiler.NewError(context, message))
  3174. }
  3175. }
  3176. // repeated string produces = 6;
  3177. v6 := compiler.MapValueForKey(m, "produces")
  3178. if v6 != nil {
  3179. v, ok := v6.([]interface{})
  3180. if ok {
  3181. x.Produces = compiler.ConvertInterfaceArrayToStringArray(v)
  3182. } else {
  3183. message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v6, v6)
  3184. errors = append(errors, compiler.NewError(context, message))
  3185. }
  3186. }
  3187. // repeated string consumes = 7;
  3188. v7 := compiler.MapValueForKey(m, "consumes")
  3189. if v7 != nil {
  3190. v, ok := v7.([]interface{})
  3191. if ok {
  3192. x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v)
  3193. } else {
  3194. message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v7, v7)
  3195. errors = append(errors, compiler.NewError(context, message))
  3196. }
  3197. }
  3198. // repeated ParametersItem parameters = 8;
  3199. v8 := compiler.MapValueForKey(m, "parameters")
  3200. if v8 != nil {
  3201. // repeated ParametersItem
  3202. x.Parameters = make([]*ParametersItem, 0)
  3203. a, ok := v8.([]interface{})
  3204. if ok {
  3205. for _, item := range a {
  3206. y, err := NewParametersItem(item, compiler.NewContext("parameters", context))
  3207. if err != nil {
  3208. errors = append(errors, err)
  3209. }
  3210. x.Parameters = append(x.Parameters, y)
  3211. }
  3212. }
  3213. }
  3214. // Responses responses = 9;
  3215. v9 := compiler.MapValueForKey(m, "responses")
  3216. if v9 != nil {
  3217. var err error
  3218. x.Responses, err = NewResponses(v9, compiler.NewContext("responses", context))
  3219. if err != nil {
  3220. errors = append(errors, err)
  3221. }
  3222. }
  3223. // repeated string schemes = 10;
  3224. v10 := compiler.MapValueForKey(m, "schemes")
  3225. if v10 != nil {
  3226. v, ok := v10.([]interface{})
  3227. if ok {
  3228. x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v)
  3229. } else {
  3230. message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v10, v10)
  3231. errors = append(errors, compiler.NewError(context, message))
  3232. }
  3233. // check for valid enum values
  3234. // [http https ws wss]
  3235. if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) {
  3236. message := fmt.Sprintf("has unexpected value for schemes: %+v", v10)
  3237. errors = append(errors, compiler.NewError(context, message))
  3238. }
  3239. }
  3240. // bool deprecated = 11;
  3241. v11 := compiler.MapValueForKey(m, "deprecated")
  3242. if v11 != nil {
  3243. x.Deprecated, ok = v11.(bool)
  3244. if !ok {
  3245. message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v11, v11)
  3246. errors = append(errors, compiler.NewError(context, message))
  3247. }
  3248. }
  3249. // repeated SecurityRequirement security = 12;
  3250. v12 := compiler.MapValueForKey(m, "security")
  3251. if v12 != nil {
  3252. // repeated SecurityRequirement
  3253. x.Security = make([]*SecurityRequirement, 0)
  3254. a, ok := v12.([]interface{})
  3255. if ok {
  3256. for _, item := range a {
  3257. y, err := NewSecurityRequirement(item, compiler.NewContext("security", context))
  3258. if err != nil {
  3259. errors = append(errors, err)
  3260. }
  3261. x.Security = append(x.Security, y)
  3262. }
  3263. }
  3264. }
  3265. // repeated NamedAny vendor_extension = 13;
  3266. // MAP: Any ^x-
  3267. x.VendorExtension = make([]*NamedAny, 0)
  3268. for _, item := range m {
  3269. k, ok := compiler.StringValue(item.Key)
  3270. if ok {
  3271. v := item.Value
  3272. if strings.HasPrefix(k, "x-") {
  3273. pair := &NamedAny{}
  3274. pair.Name = k
  3275. result := &Any{}
  3276. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  3277. if handled {
  3278. if err != nil {
  3279. errors = append(errors, err)
  3280. } else {
  3281. bytes, _ := yaml.Marshal(v)
  3282. result.Yaml = string(bytes)
  3283. result.Value = resultFromExt
  3284. pair.Value = result
  3285. }
  3286. } else {
  3287. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  3288. if err != nil {
  3289. errors = append(errors, err)
  3290. }
  3291. }
  3292. x.VendorExtension = append(x.VendorExtension, pair)
  3293. }
  3294. }
  3295. }
  3296. }
  3297. return x, compiler.NewErrorGroupOrNil(errors)
  3298. }
  3299. // NewParameter creates an object of type Parameter if possible, returning an error if not.
  3300. func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) {
  3301. errors := make([]error, 0)
  3302. x := &Parameter{}
  3303. matched := false
  3304. // BodyParameter body_parameter = 1;
  3305. {
  3306. m, ok := compiler.UnpackMap(in)
  3307. if ok {
  3308. // errors might be ok here, they mean we just don't have the right subtype
  3309. t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", context))
  3310. if matchingError == nil {
  3311. x.Oneof = &Parameter_BodyParameter{BodyParameter: t}
  3312. matched = true
  3313. } else {
  3314. errors = append(errors, matchingError)
  3315. }
  3316. }
  3317. }
  3318. // NonBodyParameter non_body_parameter = 2;
  3319. {
  3320. m, ok := compiler.UnpackMap(in)
  3321. if ok {
  3322. // errors might be ok here, they mean we just don't have the right subtype
  3323. t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context))
  3324. if matchingError == nil {
  3325. x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t}
  3326. matched = true
  3327. } else {
  3328. errors = append(errors, matchingError)
  3329. }
  3330. }
  3331. }
  3332. if matched {
  3333. // since the oneof matched one of its possibilities, discard any matching errors
  3334. errors = make([]error, 0)
  3335. }
  3336. return x, compiler.NewErrorGroupOrNil(errors)
  3337. }
  3338. // NewParameterDefinitions creates an object of type ParameterDefinitions if possible, returning an error if not.
  3339. func NewParameterDefinitions(in interface{}, context *compiler.Context) (*ParameterDefinitions, error) {
  3340. errors := make([]error, 0)
  3341. x := &ParameterDefinitions{}
  3342. m, ok := compiler.UnpackMap(in)
  3343. if !ok {
  3344. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3345. errors = append(errors, compiler.NewError(context, message))
  3346. } else {
  3347. // repeated NamedParameter additional_properties = 1;
  3348. // MAP: Parameter
  3349. x.AdditionalProperties = make([]*NamedParameter, 0)
  3350. for _, item := range m {
  3351. k, ok := compiler.StringValue(item.Key)
  3352. if ok {
  3353. v := item.Value
  3354. pair := &NamedParameter{}
  3355. pair.Name = k
  3356. var err error
  3357. pair.Value, err = NewParameter(v, compiler.NewContext(k, context))
  3358. if err != nil {
  3359. errors = append(errors, err)
  3360. }
  3361. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  3362. }
  3363. }
  3364. }
  3365. return x, compiler.NewErrorGroupOrNil(errors)
  3366. }
  3367. // NewParametersItem creates an object of type ParametersItem if possible, returning an error if not.
  3368. func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersItem, error) {
  3369. errors := make([]error, 0)
  3370. x := &ParametersItem{}
  3371. matched := false
  3372. // Parameter parameter = 1;
  3373. {
  3374. m, ok := compiler.UnpackMap(in)
  3375. if ok {
  3376. // errors might be ok here, they mean we just don't have the right subtype
  3377. t, matchingError := NewParameter(m, compiler.NewContext("parameter", context))
  3378. if matchingError == nil {
  3379. x.Oneof = &ParametersItem_Parameter{Parameter: t}
  3380. matched = true
  3381. } else {
  3382. errors = append(errors, matchingError)
  3383. }
  3384. }
  3385. }
  3386. // JsonReference json_reference = 2;
  3387. {
  3388. m, ok := compiler.UnpackMap(in)
  3389. if ok {
  3390. // errors might be ok here, they mean we just don't have the right subtype
  3391. t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context))
  3392. if matchingError == nil {
  3393. x.Oneof = &ParametersItem_JsonReference{JsonReference: t}
  3394. matched = true
  3395. } else {
  3396. errors = append(errors, matchingError)
  3397. }
  3398. }
  3399. }
  3400. if matched {
  3401. // since the oneof matched one of its possibilities, discard any matching errors
  3402. errors = make([]error, 0)
  3403. }
  3404. return x, compiler.NewErrorGroupOrNil(errors)
  3405. }
  3406. // NewPathItem creates an object of type PathItem if possible, returning an error if not.
  3407. func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) {
  3408. errors := make([]error, 0)
  3409. x := &PathItem{}
  3410. m, ok := compiler.UnpackMap(in)
  3411. if !ok {
  3412. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3413. errors = append(errors, compiler.NewError(context, message))
  3414. } else {
  3415. allowedKeys := []string{"$ref", "delete", "get", "head", "options", "parameters", "patch", "post", "put"}
  3416. allowedPatterns := []*regexp.Regexp{pattern0}
  3417. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  3418. if len(invalidKeys) > 0 {
  3419. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  3420. errors = append(errors, compiler.NewError(context, message))
  3421. }
  3422. // string _ref = 1;
  3423. v1 := compiler.MapValueForKey(m, "$ref")
  3424. if v1 != nil {
  3425. x.XRef, ok = v1.(string)
  3426. if !ok {
  3427. message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1)
  3428. errors = append(errors, compiler.NewError(context, message))
  3429. }
  3430. }
  3431. // Operation get = 2;
  3432. v2 := compiler.MapValueForKey(m, "get")
  3433. if v2 != nil {
  3434. var err error
  3435. x.Get, err = NewOperation(v2, compiler.NewContext("get", context))
  3436. if err != nil {
  3437. errors = append(errors, err)
  3438. }
  3439. }
  3440. // Operation put = 3;
  3441. v3 := compiler.MapValueForKey(m, "put")
  3442. if v3 != nil {
  3443. var err error
  3444. x.Put, err = NewOperation(v3, compiler.NewContext("put", context))
  3445. if err != nil {
  3446. errors = append(errors, err)
  3447. }
  3448. }
  3449. // Operation post = 4;
  3450. v4 := compiler.MapValueForKey(m, "post")
  3451. if v4 != nil {
  3452. var err error
  3453. x.Post, err = NewOperation(v4, compiler.NewContext("post", context))
  3454. if err != nil {
  3455. errors = append(errors, err)
  3456. }
  3457. }
  3458. // Operation delete = 5;
  3459. v5 := compiler.MapValueForKey(m, "delete")
  3460. if v5 != nil {
  3461. var err error
  3462. x.Delete, err = NewOperation(v5, compiler.NewContext("delete", context))
  3463. if err != nil {
  3464. errors = append(errors, err)
  3465. }
  3466. }
  3467. // Operation options = 6;
  3468. v6 := compiler.MapValueForKey(m, "options")
  3469. if v6 != nil {
  3470. var err error
  3471. x.Options, err = NewOperation(v6, compiler.NewContext("options", context))
  3472. if err != nil {
  3473. errors = append(errors, err)
  3474. }
  3475. }
  3476. // Operation head = 7;
  3477. v7 := compiler.MapValueForKey(m, "head")
  3478. if v7 != nil {
  3479. var err error
  3480. x.Head, err = NewOperation(v7, compiler.NewContext("head", context))
  3481. if err != nil {
  3482. errors = append(errors, err)
  3483. }
  3484. }
  3485. // Operation patch = 8;
  3486. v8 := compiler.MapValueForKey(m, "patch")
  3487. if v8 != nil {
  3488. var err error
  3489. x.Patch, err = NewOperation(v8, compiler.NewContext("patch", context))
  3490. if err != nil {
  3491. errors = append(errors, err)
  3492. }
  3493. }
  3494. // repeated ParametersItem parameters = 9;
  3495. v9 := compiler.MapValueForKey(m, "parameters")
  3496. if v9 != nil {
  3497. // repeated ParametersItem
  3498. x.Parameters = make([]*ParametersItem, 0)
  3499. a, ok := v9.([]interface{})
  3500. if ok {
  3501. for _, item := range a {
  3502. y, err := NewParametersItem(item, compiler.NewContext("parameters", context))
  3503. if err != nil {
  3504. errors = append(errors, err)
  3505. }
  3506. x.Parameters = append(x.Parameters, y)
  3507. }
  3508. }
  3509. }
  3510. // repeated NamedAny vendor_extension = 10;
  3511. // MAP: Any ^x-
  3512. x.VendorExtension = make([]*NamedAny, 0)
  3513. for _, item := range m {
  3514. k, ok := compiler.StringValue(item.Key)
  3515. if ok {
  3516. v := item.Value
  3517. if strings.HasPrefix(k, "x-") {
  3518. pair := &NamedAny{}
  3519. pair.Name = k
  3520. result := &Any{}
  3521. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  3522. if handled {
  3523. if err != nil {
  3524. errors = append(errors, err)
  3525. } else {
  3526. bytes, _ := yaml.Marshal(v)
  3527. result.Yaml = string(bytes)
  3528. result.Value = resultFromExt
  3529. pair.Value = result
  3530. }
  3531. } else {
  3532. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  3533. if err != nil {
  3534. errors = append(errors, err)
  3535. }
  3536. }
  3537. x.VendorExtension = append(x.VendorExtension, pair)
  3538. }
  3539. }
  3540. }
  3541. }
  3542. return x, compiler.NewErrorGroupOrNil(errors)
  3543. }
  3544. // NewPathParameterSubSchema creates an object of type PathParameterSubSchema if possible, returning an error if not.
  3545. func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*PathParameterSubSchema, error) {
  3546. errors := make([]error, 0)
  3547. x := &PathParameterSubSchema{}
  3548. m, ok := compiler.UnpackMap(in)
  3549. if !ok {
  3550. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3551. errors = append(errors, compiler.NewError(context, message))
  3552. } else {
  3553. requiredKeys := []string{"required"}
  3554. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  3555. if len(missingKeys) > 0 {
  3556. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  3557. errors = append(errors, compiler.NewError(context, message))
  3558. }
  3559. allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"}
  3560. allowedPatterns := []*regexp.Regexp{pattern0}
  3561. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  3562. if len(invalidKeys) > 0 {
  3563. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  3564. errors = append(errors, compiler.NewError(context, message))
  3565. }
  3566. // bool required = 1;
  3567. v1 := compiler.MapValueForKey(m, "required")
  3568. if v1 != nil {
  3569. x.Required, ok = v1.(bool)
  3570. if !ok {
  3571. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1)
  3572. errors = append(errors, compiler.NewError(context, message))
  3573. }
  3574. }
  3575. // string in = 2;
  3576. v2 := compiler.MapValueForKey(m, "in")
  3577. if v2 != nil {
  3578. x.In, ok = v2.(string)
  3579. if !ok {
  3580. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  3581. errors = append(errors, compiler.NewError(context, message))
  3582. }
  3583. // check for valid enum values
  3584. // [path]
  3585. if ok && !compiler.StringArrayContainsValue([]string{"path"}, x.In) {
  3586. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  3587. errors = append(errors, compiler.NewError(context, message))
  3588. }
  3589. }
  3590. // string description = 3;
  3591. v3 := compiler.MapValueForKey(m, "description")
  3592. if v3 != nil {
  3593. x.Description, ok = v3.(string)
  3594. if !ok {
  3595. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  3596. errors = append(errors, compiler.NewError(context, message))
  3597. }
  3598. }
  3599. // string name = 4;
  3600. v4 := compiler.MapValueForKey(m, "name")
  3601. if v4 != nil {
  3602. x.Name, ok = v4.(string)
  3603. if !ok {
  3604. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4)
  3605. errors = append(errors, compiler.NewError(context, message))
  3606. }
  3607. }
  3608. // string type = 5;
  3609. v5 := compiler.MapValueForKey(m, "type")
  3610. if v5 != nil {
  3611. x.Type, ok = v5.(string)
  3612. if !ok {
  3613. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5)
  3614. errors = append(errors, compiler.NewError(context, message))
  3615. }
  3616. // check for valid enum values
  3617. // [string number boolean integer array]
  3618. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) {
  3619. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5)
  3620. errors = append(errors, compiler.NewError(context, message))
  3621. }
  3622. }
  3623. // string format = 6;
  3624. v6 := compiler.MapValueForKey(m, "format")
  3625. if v6 != nil {
  3626. x.Format, ok = v6.(string)
  3627. if !ok {
  3628. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6)
  3629. errors = append(errors, compiler.NewError(context, message))
  3630. }
  3631. }
  3632. // PrimitivesItems items = 7;
  3633. v7 := compiler.MapValueForKey(m, "items")
  3634. if v7 != nil {
  3635. var err error
  3636. x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context))
  3637. if err != nil {
  3638. errors = append(errors, err)
  3639. }
  3640. }
  3641. // string collection_format = 8;
  3642. v8 := compiler.MapValueForKey(m, "collectionFormat")
  3643. if v8 != nil {
  3644. x.CollectionFormat, ok = v8.(string)
  3645. if !ok {
  3646. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8)
  3647. errors = append(errors, compiler.NewError(context, message))
  3648. }
  3649. // check for valid enum values
  3650. // [csv ssv tsv pipes]
  3651. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) {
  3652. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8)
  3653. errors = append(errors, compiler.NewError(context, message))
  3654. }
  3655. }
  3656. // Any default = 9;
  3657. v9 := compiler.MapValueForKey(m, "default")
  3658. if v9 != nil {
  3659. var err error
  3660. x.Default, err = NewAny(v9, compiler.NewContext("default", context))
  3661. if err != nil {
  3662. errors = append(errors, err)
  3663. }
  3664. }
  3665. // float maximum = 10;
  3666. v10 := compiler.MapValueForKey(m, "maximum")
  3667. if v10 != nil {
  3668. switch v10 := v10.(type) {
  3669. case float64:
  3670. x.Maximum = v10
  3671. case float32:
  3672. x.Maximum = float64(v10)
  3673. case uint64:
  3674. x.Maximum = float64(v10)
  3675. case uint32:
  3676. x.Maximum = float64(v10)
  3677. case int64:
  3678. x.Maximum = float64(v10)
  3679. case int32:
  3680. x.Maximum = float64(v10)
  3681. case int:
  3682. x.Maximum = float64(v10)
  3683. default:
  3684. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10)
  3685. errors = append(errors, compiler.NewError(context, message))
  3686. }
  3687. }
  3688. // bool exclusive_maximum = 11;
  3689. v11 := compiler.MapValueForKey(m, "exclusiveMaximum")
  3690. if v11 != nil {
  3691. x.ExclusiveMaximum, ok = v11.(bool)
  3692. if !ok {
  3693. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11)
  3694. errors = append(errors, compiler.NewError(context, message))
  3695. }
  3696. }
  3697. // float minimum = 12;
  3698. v12 := compiler.MapValueForKey(m, "minimum")
  3699. if v12 != nil {
  3700. switch v12 := v12.(type) {
  3701. case float64:
  3702. x.Minimum = v12
  3703. case float32:
  3704. x.Minimum = float64(v12)
  3705. case uint64:
  3706. x.Minimum = float64(v12)
  3707. case uint32:
  3708. x.Minimum = float64(v12)
  3709. case int64:
  3710. x.Minimum = float64(v12)
  3711. case int32:
  3712. x.Minimum = float64(v12)
  3713. case int:
  3714. x.Minimum = float64(v12)
  3715. default:
  3716. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12)
  3717. errors = append(errors, compiler.NewError(context, message))
  3718. }
  3719. }
  3720. // bool exclusive_minimum = 13;
  3721. v13 := compiler.MapValueForKey(m, "exclusiveMinimum")
  3722. if v13 != nil {
  3723. x.ExclusiveMinimum, ok = v13.(bool)
  3724. if !ok {
  3725. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13)
  3726. errors = append(errors, compiler.NewError(context, message))
  3727. }
  3728. }
  3729. // int64 max_length = 14;
  3730. v14 := compiler.MapValueForKey(m, "maxLength")
  3731. if v14 != nil {
  3732. t, ok := v14.(int)
  3733. if ok {
  3734. x.MaxLength = int64(t)
  3735. } else {
  3736. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14)
  3737. errors = append(errors, compiler.NewError(context, message))
  3738. }
  3739. }
  3740. // int64 min_length = 15;
  3741. v15 := compiler.MapValueForKey(m, "minLength")
  3742. if v15 != nil {
  3743. t, ok := v15.(int)
  3744. if ok {
  3745. x.MinLength = int64(t)
  3746. } else {
  3747. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15)
  3748. errors = append(errors, compiler.NewError(context, message))
  3749. }
  3750. }
  3751. // string pattern = 16;
  3752. v16 := compiler.MapValueForKey(m, "pattern")
  3753. if v16 != nil {
  3754. x.Pattern, ok = v16.(string)
  3755. if !ok {
  3756. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16)
  3757. errors = append(errors, compiler.NewError(context, message))
  3758. }
  3759. }
  3760. // int64 max_items = 17;
  3761. v17 := compiler.MapValueForKey(m, "maxItems")
  3762. if v17 != nil {
  3763. t, ok := v17.(int)
  3764. if ok {
  3765. x.MaxItems = int64(t)
  3766. } else {
  3767. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17)
  3768. errors = append(errors, compiler.NewError(context, message))
  3769. }
  3770. }
  3771. // int64 min_items = 18;
  3772. v18 := compiler.MapValueForKey(m, "minItems")
  3773. if v18 != nil {
  3774. t, ok := v18.(int)
  3775. if ok {
  3776. x.MinItems = int64(t)
  3777. } else {
  3778. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18)
  3779. errors = append(errors, compiler.NewError(context, message))
  3780. }
  3781. }
  3782. // bool unique_items = 19;
  3783. v19 := compiler.MapValueForKey(m, "uniqueItems")
  3784. if v19 != nil {
  3785. x.UniqueItems, ok = v19.(bool)
  3786. if !ok {
  3787. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19)
  3788. errors = append(errors, compiler.NewError(context, message))
  3789. }
  3790. }
  3791. // repeated Any enum = 20;
  3792. v20 := compiler.MapValueForKey(m, "enum")
  3793. if v20 != nil {
  3794. // repeated Any
  3795. x.Enum = make([]*Any, 0)
  3796. a, ok := v20.([]interface{})
  3797. if ok {
  3798. for _, item := range a {
  3799. y, err := NewAny(item, compiler.NewContext("enum", context))
  3800. if err != nil {
  3801. errors = append(errors, err)
  3802. }
  3803. x.Enum = append(x.Enum, y)
  3804. }
  3805. }
  3806. }
  3807. // float multiple_of = 21;
  3808. v21 := compiler.MapValueForKey(m, "multipleOf")
  3809. if v21 != nil {
  3810. switch v21 := v21.(type) {
  3811. case float64:
  3812. x.MultipleOf = v21
  3813. case float32:
  3814. x.MultipleOf = float64(v21)
  3815. case uint64:
  3816. x.MultipleOf = float64(v21)
  3817. case uint32:
  3818. x.MultipleOf = float64(v21)
  3819. case int64:
  3820. x.MultipleOf = float64(v21)
  3821. case int32:
  3822. x.MultipleOf = float64(v21)
  3823. case int:
  3824. x.MultipleOf = float64(v21)
  3825. default:
  3826. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21)
  3827. errors = append(errors, compiler.NewError(context, message))
  3828. }
  3829. }
  3830. // repeated NamedAny vendor_extension = 22;
  3831. // MAP: Any ^x-
  3832. x.VendorExtension = make([]*NamedAny, 0)
  3833. for _, item := range m {
  3834. k, ok := compiler.StringValue(item.Key)
  3835. if ok {
  3836. v := item.Value
  3837. if strings.HasPrefix(k, "x-") {
  3838. pair := &NamedAny{}
  3839. pair.Name = k
  3840. result := &Any{}
  3841. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  3842. if handled {
  3843. if err != nil {
  3844. errors = append(errors, err)
  3845. } else {
  3846. bytes, _ := yaml.Marshal(v)
  3847. result.Yaml = string(bytes)
  3848. result.Value = resultFromExt
  3849. pair.Value = result
  3850. }
  3851. } else {
  3852. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  3853. if err != nil {
  3854. errors = append(errors, err)
  3855. }
  3856. }
  3857. x.VendorExtension = append(x.VendorExtension, pair)
  3858. }
  3859. }
  3860. }
  3861. }
  3862. return x, compiler.NewErrorGroupOrNil(errors)
  3863. }
  3864. // NewPaths creates an object of type Paths if possible, returning an error if not.
  3865. func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) {
  3866. errors := make([]error, 0)
  3867. x := &Paths{}
  3868. m, ok := compiler.UnpackMap(in)
  3869. if !ok {
  3870. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3871. errors = append(errors, compiler.NewError(context, message))
  3872. } else {
  3873. allowedKeys := []string{}
  3874. allowedPatterns := []*regexp.Regexp{pattern0, pattern1}
  3875. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  3876. if len(invalidKeys) > 0 {
  3877. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  3878. errors = append(errors, compiler.NewError(context, message))
  3879. }
  3880. // repeated NamedAny vendor_extension = 1;
  3881. // MAP: Any ^x-
  3882. x.VendorExtension = make([]*NamedAny, 0)
  3883. for _, item := range m {
  3884. k, ok := compiler.StringValue(item.Key)
  3885. if ok {
  3886. v := item.Value
  3887. if strings.HasPrefix(k, "x-") {
  3888. pair := &NamedAny{}
  3889. pair.Name = k
  3890. result := &Any{}
  3891. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  3892. if handled {
  3893. if err != nil {
  3894. errors = append(errors, err)
  3895. } else {
  3896. bytes, _ := yaml.Marshal(v)
  3897. result.Yaml = string(bytes)
  3898. result.Value = resultFromExt
  3899. pair.Value = result
  3900. }
  3901. } else {
  3902. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  3903. if err != nil {
  3904. errors = append(errors, err)
  3905. }
  3906. }
  3907. x.VendorExtension = append(x.VendorExtension, pair)
  3908. }
  3909. }
  3910. }
  3911. // repeated NamedPathItem path = 2;
  3912. // MAP: PathItem ^/
  3913. x.Path = make([]*NamedPathItem, 0)
  3914. for _, item := range m {
  3915. k, ok := compiler.StringValue(item.Key)
  3916. if ok {
  3917. v := item.Value
  3918. if strings.HasPrefix(k, "/") {
  3919. pair := &NamedPathItem{}
  3920. pair.Name = k
  3921. var err error
  3922. pair.Value, err = NewPathItem(v, compiler.NewContext(k, context))
  3923. if err != nil {
  3924. errors = append(errors, err)
  3925. }
  3926. x.Path = append(x.Path, pair)
  3927. }
  3928. }
  3929. }
  3930. }
  3931. return x, compiler.NewErrorGroupOrNil(errors)
  3932. }
  3933. // NewPrimitivesItems creates an object of type PrimitivesItems if possible, returning an error if not.
  3934. func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesItems, error) {
  3935. errors := make([]error, 0)
  3936. x := &PrimitivesItems{}
  3937. m, ok := compiler.UnpackMap(in)
  3938. if !ok {
  3939. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  3940. errors = append(errors, compiler.NewError(context, message))
  3941. } else {
  3942. allowedKeys := []string{"collectionFormat", "default", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"}
  3943. allowedPatterns := []*regexp.Regexp{pattern0}
  3944. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  3945. if len(invalidKeys) > 0 {
  3946. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  3947. errors = append(errors, compiler.NewError(context, message))
  3948. }
  3949. // string type = 1;
  3950. v1 := compiler.MapValueForKey(m, "type")
  3951. if v1 != nil {
  3952. x.Type, ok = v1.(string)
  3953. if !ok {
  3954. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  3955. errors = append(errors, compiler.NewError(context, message))
  3956. }
  3957. // check for valid enum values
  3958. // [string number integer boolean array]
  3959. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) {
  3960. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
  3961. errors = append(errors, compiler.NewError(context, message))
  3962. }
  3963. }
  3964. // string format = 2;
  3965. v2 := compiler.MapValueForKey(m, "format")
  3966. if v2 != nil {
  3967. x.Format, ok = v2.(string)
  3968. if !ok {
  3969. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2)
  3970. errors = append(errors, compiler.NewError(context, message))
  3971. }
  3972. }
  3973. // PrimitivesItems items = 3;
  3974. v3 := compiler.MapValueForKey(m, "items")
  3975. if v3 != nil {
  3976. var err error
  3977. x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context))
  3978. if err != nil {
  3979. errors = append(errors, err)
  3980. }
  3981. }
  3982. // string collection_format = 4;
  3983. v4 := compiler.MapValueForKey(m, "collectionFormat")
  3984. if v4 != nil {
  3985. x.CollectionFormat, ok = v4.(string)
  3986. if !ok {
  3987. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4)
  3988. errors = append(errors, compiler.NewError(context, message))
  3989. }
  3990. // check for valid enum values
  3991. // [csv ssv tsv pipes]
  3992. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) {
  3993. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4)
  3994. errors = append(errors, compiler.NewError(context, message))
  3995. }
  3996. }
  3997. // Any default = 5;
  3998. v5 := compiler.MapValueForKey(m, "default")
  3999. if v5 != nil {
  4000. var err error
  4001. x.Default, err = NewAny(v5, compiler.NewContext("default", context))
  4002. if err != nil {
  4003. errors = append(errors, err)
  4004. }
  4005. }
  4006. // float maximum = 6;
  4007. v6 := compiler.MapValueForKey(m, "maximum")
  4008. if v6 != nil {
  4009. switch v6 := v6.(type) {
  4010. case float64:
  4011. x.Maximum = v6
  4012. case float32:
  4013. x.Maximum = float64(v6)
  4014. case uint64:
  4015. x.Maximum = float64(v6)
  4016. case uint32:
  4017. x.Maximum = float64(v6)
  4018. case int64:
  4019. x.Maximum = float64(v6)
  4020. case int32:
  4021. x.Maximum = float64(v6)
  4022. case int:
  4023. x.Maximum = float64(v6)
  4024. default:
  4025. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6)
  4026. errors = append(errors, compiler.NewError(context, message))
  4027. }
  4028. }
  4029. // bool exclusive_maximum = 7;
  4030. v7 := compiler.MapValueForKey(m, "exclusiveMaximum")
  4031. if v7 != nil {
  4032. x.ExclusiveMaximum, ok = v7.(bool)
  4033. if !ok {
  4034. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7)
  4035. errors = append(errors, compiler.NewError(context, message))
  4036. }
  4037. }
  4038. // float minimum = 8;
  4039. v8 := compiler.MapValueForKey(m, "minimum")
  4040. if v8 != nil {
  4041. switch v8 := v8.(type) {
  4042. case float64:
  4043. x.Minimum = v8
  4044. case float32:
  4045. x.Minimum = float64(v8)
  4046. case uint64:
  4047. x.Minimum = float64(v8)
  4048. case uint32:
  4049. x.Minimum = float64(v8)
  4050. case int64:
  4051. x.Minimum = float64(v8)
  4052. case int32:
  4053. x.Minimum = float64(v8)
  4054. case int:
  4055. x.Minimum = float64(v8)
  4056. default:
  4057. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8)
  4058. errors = append(errors, compiler.NewError(context, message))
  4059. }
  4060. }
  4061. // bool exclusive_minimum = 9;
  4062. v9 := compiler.MapValueForKey(m, "exclusiveMinimum")
  4063. if v9 != nil {
  4064. x.ExclusiveMinimum, ok = v9.(bool)
  4065. if !ok {
  4066. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9)
  4067. errors = append(errors, compiler.NewError(context, message))
  4068. }
  4069. }
  4070. // int64 max_length = 10;
  4071. v10 := compiler.MapValueForKey(m, "maxLength")
  4072. if v10 != nil {
  4073. t, ok := v10.(int)
  4074. if ok {
  4075. x.MaxLength = int64(t)
  4076. } else {
  4077. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10)
  4078. errors = append(errors, compiler.NewError(context, message))
  4079. }
  4080. }
  4081. // int64 min_length = 11;
  4082. v11 := compiler.MapValueForKey(m, "minLength")
  4083. if v11 != nil {
  4084. t, ok := v11.(int)
  4085. if ok {
  4086. x.MinLength = int64(t)
  4087. } else {
  4088. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11)
  4089. errors = append(errors, compiler.NewError(context, message))
  4090. }
  4091. }
  4092. // string pattern = 12;
  4093. v12 := compiler.MapValueForKey(m, "pattern")
  4094. if v12 != nil {
  4095. x.Pattern, ok = v12.(string)
  4096. if !ok {
  4097. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12)
  4098. errors = append(errors, compiler.NewError(context, message))
  4099. }
  4100. }
  4101. // int64 max_items = 13;
  4102. v13 := compiler.MapValueForKey(m, "maxItems")
  4103. if v13 != nil {
  4104. t, ok := v13.(int)
  4105. if ok {
  4106. x.MaxItems = int64(t)
  4107. } else {
  4108. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13)
  4109. errors = append(errors, compiler.NewError(context, message))
  4110. }
  4111. }
  4112. // int64 min_items = 14;
  4113. v14 := compiler.MapValueForKey(m, "minItems")
  4114. if v14 != nil {
  4115. t, ok := v14.(int)
  4116. if ok {
  4117. x.MinItems = int64(t)
  4118. } else {
  4119. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14)
  4120. errors = append(errors, compiler.NewError(context, message))
  4121. }
  4122. }
  4123. // bool unique_items = 15;
  4124. v15 := compiler.MapValueForKey(m, "uniqueItems")
  4125. if v15 != nil {
  4126. x.UniqueItems, ok = v15.(bool)
  4127. if !ok {
  4128. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15)
  4129. errors = append(errors, compiler.NewError(context, message))
  4130. }
  4131. }
  4132. // repeated Any enum = 16;
  4133. v16 := compiler.MapValueForKey(m, "enum")
  4134. if v16 != nil {
  4135. // repeated Any
  4136. x.Enum = make([]*Any, 0)
  4137. a, ok := v16.([]interface{})
  4138. if ok {
  4139. for _, item := range a {
  4140. y, err := NewAny(item, compiler.NewContext("enum", context))
  4141. if err != nil {
  4142. errors = append(errors, err)
  4143. }
  4144. x.Enum = append(x.Enum, y)
  4145. }
  4146. }
  4147. }
  4148. // float multiple_of = 17;
  4149. v17 := compiler.MapValueForKey(m, "multipleOf")
  4150. if v17 != nil {
  4151. switch v17 := v17.(type) {
  4152. case float64:
  4153. x.MultipleOf = v17
  4154. case float32:
  4155. x.MultipleOf = float64(v17)
  4156. case uint64:
  4157. x.MultipleOf = float64(v17)
  4158. case uint32:
  4159. x.MultipleOf = float64(v17)
  4160. case int64:
  4161. x.MultipleOf = float64(v17)
  4162. case int32:
  4163. x.MultipleOf = float64(v17)
  4164. case int:
  4165. x.MultipleOf = float64(v17)
  4166. default:
  4167. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17)
  4168. errors = append(errors, compiler.NewError(context, message))
  4169. }
  4170. }
  4171. // repeated NamedAny vendor_extension = 18;
  4172. // MAP: Any ^x-
  4173. x.VendorExtension = make([]*NamedAny, 0)
  4174. for _, item := range m {
  4175. k, ok := compiler.StringValue(item.Key)
  4176. if ok {
  4177. v := item.Value
  4178. if strings.HasPrefix(k, "x-") {
  4179. pair := &NamedAny{}
  4180. pair.Name = k
  4181. result := &Any{}
  4182. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  4183. if handled {
  4184. if err != nil {
  4185. errors = append(errors, err)
  4186. } else {
  4187. bytes, _ := yaml.Marshal(v)
  4188. result.Yaml = string(bytes)
  4189. result.Value = resultFromExt
  4190. pair.Value = result
  4191. }
  4192. } else {
  4193. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  4194. if err != nil {
  4195. errors = append(errors, err)
  4196. }
  4197. }
  4198. x.VendorExtension = append(x.VendorExtension, pair)
  4199. }
  4200. }
  4201. }
  4202. }
  4203. return x, compiler.NewErrorGroupOrNil(errors)
  4204. }
  4205. // NewProperties creates an object of type Properties if possible, returning an error if not.
  4206. func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) {
  4207. errors := make([]error, 0)
  4208. x := &Properties{}
  4209. m, ok := compiler.UnpackMap(in)
  4210. if !ok {
  4211. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4212. errors = append(errors, compiler.NewError(context, message))
  4213. } else {
  4214. // repeated NamedSchema additional_properties = 1;
  4215. // MAP: Schema
  4216. x.AdditionalProperties = make([]*NamedSchema, 0)
  4217. for _, item := range m {
  4218. k, ok := compiler.StringValue(item.Key)
  4219. if ok {
  4220. v := item.Value
  4221. pair := &NamedSchema{}
  4222. pair.Name = k
  4223. var err error
  4224. pair.Value, err = NewSchema(v, compiler.NewContext(k, context))
  4225. if err != nil {
  4226. errors = append(errors, err)
  4227. }
  4228. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  4229. }
  4230. }
  4231. }
  4232. return x, compiler.NewErrorGroupOrNil(errors)
  4233. }
  4234. // NewQueryParameterSubSchema creates an object of type QueryParameterSubSchema if possible, returning an error if not.
  4235. func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*QueryParameterSubSchema, error) {
  4236. errors := make([]error, 0)
  4237. x := &QueryParameterSubSchema{}
  4238. m, ok := compiler.UnpackMap(in)
  4239. if !ok {
  4240. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4241. errors = append(errors, compiler.NewError(context, message))
  4242. } else {
  4243. allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"}
  4244. allowedPatterns := []*regexp.Regexp{pattern0}
  4245. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  4246. if len(invalidKeys) > 0 {
  4247. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  4248. errors = append(errors, compiler.NewError(context, message))
  4249. }
  4250. // bool required = 1;
  4251. v1 := compiler.MapValueForKey(m, "required")
  4252. if v1 != nil {
  4253. x.Required, ok = v1.(bool)
  4254. if !ok {
  4255. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1)
  4256. errors = append(errors, compiler.NewError(context, message))
  4257. }
  4258. }
  4259. // string in = 2;
  4260. v2 := compiler.MapValueForKey(m, "in")
  4261. if v2 != nil {
  4262. x.In, ok = v2.(string)
  4263. if !ok {
  4264. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  4265. errors = append(errors, compiler.NewError(context, message))
  4266. }
  4267. // check for valid enum values
  4268. // [query]
  4269. if ok && !compiler.StringArrayContainsValue([]string{"query"}, x.In) {
  4270. message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
  4271. errors = append(errors, compiler.NewError(context, message))
  4272. }
  4273. }
  4274. // string description = 3;
  4275. v3 := compiler.MapValueForKey(m, "description")
  4276. if v3 != nil {
  4277. x.Description, ok = v3.(string)
  4278. if !ok {
  4279. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
  4280. errors = append(errors, compiler.NewError(context, message))
  4281. }
  4282. }
  4283. // string name = 4;
  4284. v4 := compiler.MapValueForKey(m, "name")
  4285. if v4 != nil {
  4286. x.Name, ok = v4.(string)
  4287. if !ok {
  4288. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4)
  4289. errors = append(errors, compiler.NewError(context, message))
  4290. }
  4291. }
  4292. // bool allow_empty_value = 5;
  4293. v5 := compiler.MapValueForKey(m, "allowEmptyValue")
  4294. if v5 != nil {
  4295. x.AllowEmptyValue, ok = v5.(bool)
  4296. if !ok {
  4297. message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5)
  4298. errors = append(errors, compiler.NewError(context, message))
  4299. }
  4300. }
  4301. // string type = 6;
  4302. v6 := compiler.MapValueForKey(m, "type")
  4303. if v6 != nil {
  4304. x.Type, ok = v6.(string)
  4305. if !ok {
  4306. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  4307. errors = append(errors, compiler.NewError(context, message))
  4308. }
  4309. // check for valid enum values
  4310. // [string number boolean integer array]
  4311. if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) {
  4312. message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6)
  4313. errors = append(errors, compiler.NewError(context, message))
  4314. }
  4315. }
  4316. // string format = 7;
  4317. v7 := compiler.MapValueForKey(m, "format")
  4318. if v7 != nil {
  4319. x.Format, ok = v7.(string)
  4320. if !ok {
  4321. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7)
  4322. errors = append(errors, compiler.NewError(context, message))
  4323. }
  4324. }
  4325. // PrimitivesItems items = 8;
  4326. v8 := compiler.MapValueForKey(m, "items")
  4327. if v8 != nil {
  4328. var err error
  4329. x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context))
  4330. if err != nil {
  4331. errors = append(errors, err)
  4332. }
  4333. }
  4334. // string collection_format = 9;
  4335. v9 := compiler.MapValueForKey(m, "collectionFormat")
  4336. if v9 != nil {
  4337. x.CollectionFormat, ok = v9.(string)
  4338. if !ok {
  4339. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9)
  4340. errors = append(errors, compiler.NewError(context, message))
  4341. }
  4342. // check for valid enum values
  4343. // [csv ssv tsv pipes multi]
  4344. if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) {
  4345. message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9)
  4346. errors = append(errors, compiler.NewError(context, message))
  4347. }
  4348. }
  4349. // Any default = 10;
  4350. v10 := compiler.MapValueForKey(m, "default")
  4351. if v10 != nil {
  4352. var err error
  4353. x.Default, err = NewAny(v10, compiler.NewContext("default", context))
  4354. if err != nil {
  4355. errors = append(errors, err)
  4356. }
  4357. }
  4358. // float maximum = 11;
  4359. v11 := compiler.MapValueForKey(m, "maximum")
  4360. if v11 != nil {
  4361. switch v11 := v11.(type) {
  4362. case float64:
  4363. x.Maximum = v11
  4364. case float32:
  4365. x.Maximum = float64(v11)
  4366. case uint64:
  4367. x.Maximum = float64(v11)
  4368. case uint32:
  4369. x.Maximum = float64(v11)
  4370. case int64:
  4371. x.Maximum = float64(v11)
  4372. case int32:
  4373. x.Maximum = float64(v11)
  4374. case int:
  4375. x.Maximum = float64(v11)
  4376. default:
  4377. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11)
  4378. errors = append(errors, compiler.NewError(context, message))
  4379. }
  4380. }
  4381. // bool exclusive_maximum = 12;
  4382. v12 := compiler.MapValueForKey(m, "exclusiveMaximum")
  4383. if v12 != nil {
  4384. x.ExclusiveMaximum, ok = v12.(bool)
  4385. if !ok {
  4386. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12)
  4387. errors = append(errors, compiler.NewError(context, message))
  4388. }
  4389. }
  4390. // float minimum = 13;
  4391. v13 := compiler.MapValueForKey(m, "minimum")
  4392. if v13 != nil {
  4393. switch v13 := v13.(type) {
  4394. case float64:
  4395. x.Minimum = v13
  4396. case float32:
  4397. x.Minimum = float64(v13)
  4398. case uint64:
  4399. x.Minimum = float64(v13)
  4400. case uint32:
  4401. x.Minimum = float64(v13)
  4402. case int64:
  4403. x.Minimum = float64(v13)
  4404. case int32:
  4405. x.Minimum = float64(v13)
  4406. case int:
  4407. x.Minimum = float64(v13)
  4408. default:
  4409. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13)
  4410. errors = append(errors, compiler.NewError(context, message))
  4411. }
  4412. }
  4413. // bool exclusive_minimum = 14;
  4414. v14 := compiler.MapValueForKey(m, "exclusiveMinimum")
  4415. if v14 != nil {
  4416. x.ExclusiveMinimum, ok = v14.(bool)
  4417. if !ok {
  4418. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14)
  4419. errors = append(errors, compiler.NewError(context, message))
  4420. }
  4421. }
  4422. // int64 max_length = 15;
  4423. v15 := compiler.MapValueForKey(m, "maxLength")
  4424. if v15 != nil {
  4425. t, ok := v15.(int)
  4426. if ok {
  4427. x.MaxLength = int64(t)
  4428. } else {
  4429. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15)
  4430. errors = append(errors, compiler.NewError(context, message))
  4431. }
  4432. }
  4433. // int64 min_length = 16;
  4434. v16 := compiler.MapValueForKey(m, "minLength")
  4435. if v16 != nil {
  4436. t, ok := v16.(int)
  4437. if ok {
  4438. x.MinLength = int64(t)
  4439. } else {
  4440. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16)
  4441. errors = append(errors, compiler.NewError(context, message))
  4442. }
  4443. }
  4444. // string pattern = 17;
  4445. v17 := compiler.MapValueForKey(m, "pattern")
  4446. if v17 != nil {
  4447. x.Pattern, ok = v17.(string)
  4448. if !ok {
  4449. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17)
  4450. errors = append(errors, compiler.NewError(context, message))
  4451. }
  4452. }
  4453. // int64 max_items = 18;
  4454. v18 := compiler.MapValueForKey(m, "maxItems")
  4455. if v18 != nil {
  4456. t, ok := v18.(int)
  4457. if ok {
  4458. x.MaxItems = int64(t)
  4459. } else {
  4460. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18)
  4461. errors = append(errors, compiler.NewError(context, message))
  4462. }
  4463. }
  4464. // int64 min_items = 19;
  4465. v19 := compiler.MapValueForKey(m, "minItems")
  4466. if v19 != nil {
  4467. t, ok := v19.(int)
  4468. if ok {
  4469. x.MinItems = int64(t)
  4470. } else {
  4471. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19)
  4472. errors = append(errors, compiler.NewError(context, message))
  4473. }
  4474. }
  4475. // bool unique_items = 20;
  4476. v20 := compiler.MapValueForKey(m, "uniqueItems")
  4477. if v20 != nil {
  4478. x.UniqueItems, ok = v20.(bool)
  4479. if !ok {
  4480. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20)
  4481. errors = append(errors, compiler.NewError(context, message))
  4482. }
  4483. }
  4484. // repeated Any enum = 21;
  4485. v21 := compiler.MapValueForKey(m, "enum")
  4486. if v21 != nil {
  4487. // repeated Any
  4488. x.Enum = make([]*Any, 0)
  4489. a, ok := v21.([]interface{})
  4490. if ok {
  4491. for _, item := range a {
  4492. y, err := NewAny(item, compiler.NewContext("enum", context))
  4493. if err != nil {
  4494. errors = append(errors, err)
  4495. }
  4496. x.Enum = append(x.Enum, y)
  4497. }
  4498. }
  4499. }
  4500. // float multiple_of = 22;
  4501. v22 := compiler.MapValueForKey(m, "multipleOf")
  4502. if v22 != nil {
  4503. switch v22 := v22.(type) {
  4504. case float64:
  4505. x.MultipleOf = v22
  4506. case float32:
  4507. x.MultipleOf = float64(v22)
  4508. case uint64:
  4509. x.MultipleOf = float64(v22)
  4510. case uint32:
  4511. x.MultipleOf = float64(v22)
  4512. case int64:
  4513. x.MultipleOf = float64(v22)
  4514. case int32:
  4515. x.MultipleOf = float64(v22)
  4516. case int:
  4517. x.MultipleOf = float64(v22)
  4518. default:
  4519. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22)
  4520. errors = append(errors, compiler.NewError(context, message))
  4521. }
  4522. }
  4523. // repeated NamedAny vendor_extension = 23;
  4524. // MAP: Any ^x-
  4525. x.VendorExtension = make([]*NamedAny, 0)
  4526. for _, item := range m {
  4527. k, ok := compiler.StringValue(item.Key)
  4528. if ok {
  4529. v := item.Value
  4530. if strings.HasPrefix(k, "x-") {
  4531. pair := &NamedAny{}
  4532. pair.Name = k
  4533. result := &Any{}
  4534. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  4535. if handled {
  4536. if err != nil {
  4537. errors = append(errors, err)
  4538. } else {
  4539. bytes, _ := yaml.Marshal(v)
  4540. result.Yaml = string(bytes)
  4541. result.Value = resultFromExt
  4542. pair.Value = result
  4543. }
  4544. } else {
  4545. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  4546. if err != nil {
  4547. errors = append(errors, err)
  4548. }
  4549. }
  4550. x.VendorExtension = append(x.VendorExtension, pair)
  4551. }
  4552. }
  4553. }
  4554. }
  4555. return x, compiler.NewErrorGroupOrNil(errors)
  4556. }
  4557. // NewResponse creates an object of type Response if possible, returning an error if not.
  4558. func NewResponse(in interface{}, context *compiler.Context) (*Response, error) {
  4559. errors := make([]error, 0)
  4560. x := &Response{}
  4561. m, ok := compiler.UnpackMap(in)
  4562. if !ok {
  4563. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4564. errors = append(errors, compiler.NewError(context, message))
  4565. } else {
  4566. requiredKeys := []string{"description"}
  4567. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  4568. if len(missingKeys) > 0 {
  4569. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  4570. errors = append(errors, compiler.NewError(context, message))
  4571. }
  4572. allowedKeys := []string{"description", "examples", "headers", "schema"}
  4573. allowedPatterns := []*regexp.Regexp{pattern0}
  4574. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  4575. if len(invalidKeys) > 0 {
  4576. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  4577. errors = append(errors, compiler.NewError(context, message))
  4578. }
  4579. // string description = 1;
  4580. v1 := compiler.MapValueForKey(m, "description")
  4581. if v1 != nil {
  4582. x.Description, ok = v1.(string)
  4583. if !ok {
  4584. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
  4585. errors = append(errors, compiler.NewError(context, message))
  4586. }
  4587. }
  4588. // SchemaItem schema = 2;
  4589. v2 := compiler.MapValueForKey(m, "schema")
  4590. if v2 != nil {
  4591. var err error
  4592. x.Schema, err = NewSchemaItem(v2, compiler.NewContext("schema", context))
  4593. if err != nil {
  4594. errors = append(errors, err)
  4595. }
  4596. }
  4597. // Headers headers = 3;
  4598. v3 := compiler.MapValueForKey(m, "headers")
  4599. if v3 != nil {
  4600. var err error
  4601. x.Headers, err = NewHeaders(v3, compiler.NewContext("headers", context))
  4602. if err != nil {
  4603. errors = append(errors, err)
  4604. }
  4605. }
  4606. // Examples examples = 4;
  4607. v4 := compiler.MapValueForKey(m, "examples")
  4608. if v4 != nil {
  4609. var err error
  4610. x.Examples, err = NewExamples(v4, compiler.NewContext("examples", context))
  4611. if err != nil {
  4612. errors = append(errors, err)
  4613. }
  4614. }
  4615. // repeated NamedAny vendor_extension = 5;
  4616. // MAP: Any ^x-
  4617. x.VendorExtension = make([]*NamedAny, 0)
  4618. for _, item := range m {
  4619. k, ok := compiler.StringValue(item.Key)
  4620. if ok {
  4621. v := item.Value
  4622. if strings.HasPrefix(k, "x-") {
  4623. pair := &NamedAny{}
  4624. pair.Name = k
  4625. result := &Any{}
  4626. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  4627. if handled {
  4628. if err != nil {
  4629. errors = append(errors, err)
  4630. } else {
  4631. bytes, _ := yaml.Marshal(v)
  4632. result.Yaml = string(bytes)
  4633. result.Value = resultFromExt
  4634. pair.Value = result
  4635. }
  4636. } else {
  4637. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  4638. if err != nil {
  4639. errors = append(errors, err)
  4640. }
  4641. }
  4642. x.VendorExtension = append(x.VendorExtension, pair)
  4643. }
  4644. }
  4645. }
  4646. }
  4647. return x, compiler.NewErrorGroupOrNil(errors)
  4648. }
  4649. // NewResponseDefinitions creates an object of type ResponseDefinitions if possible, returning an error if not.
  4650. func NewResponseDefinitions(in interface{}, context *compiler.Context) (*ResponseDefinitions, error) {
  4651. errors := make([]error, 0)
  4652. x := &ResponseDefinitions{}
  4653. m, ok := compiler.UnpackMap(in)
  4654. if !ok {
  4655. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4656. errors = append(errors, compiler.NewError(context, message))
  4657. } else {
  4658. // repeated NamedResponse additional_properties = 1;
  4659. // MAP: Response
  4660. x.AdditionalProperties = make([]*NamedResponse, 0)
  4661. for _, item := range m {
  4662. k, ok := compiler.StringValue(item.Key)
  4663. if ok {
  4664. v := item.Value
  4665. pair := &NamedResponse{}
  4666. pair.Name = k
  4667. var err error
  4668. pair.Value, err = NewResponse(v, compiler.NewContext(k, context))
  4669. if err != nil {
  4670. errors = append(errors, err)
  4671. }
  4672. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  4673. }
  4674. }
  4675. }
  4676. return x, compiler.NewErrorGroupOrNil(errors)
  4677. }
  4678. // NewResponseValue creates an object of type ResponseValue if possible, returning an error if not.
  4679. func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue, error) {
  4680. errors := make([]error, 0)
  4681. x := &ResponseValue{}
  4682. matched := false
  4683. // Response response = 1;
  4684. {
  4685. m, ok := compiler.UnpackMap(in)
  4686. if ok {
  4687. // errors might be ok here, they mean we just don't have the right subtype
  4688. t, matchingError := NewResponse(m, compiler.NewContext("response", context))
  4689. if matchingError == nil {
  4690. x.Oneof = &ResponseValue_Response{Response: t}
  4691. matched = true
  4692. } else {
  4693. errors = append(errors, matchingError)
  4694. }
  4695. }
  4696. }
  4697. // JsonReference json_reference = 2;
  4698. {
  4699. m, ok := compiler.UnpackMap(in)
  4700. if ok {
  4701. // errors might be ok here, they mean we just don't have the right subtype
  4702. t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context))
  4703. if matchingError == nil {
  4704. x.Oneof = &ResponseValue_JsonReference{JsonReference: t}
  4705. matched = true
  4706. } else {
  4707. errors = append(errors, matchingError)
  4708. }
  4709. }
  4710. }
  4711. if matched {
  4712. // since the oneof matched one of its possibilities, discard any matching errors
  4713. errors = make([]error, 0)
  4714. }
  4715. return x, compiler.NewErrorGroupOrNil(errors)
  4716. }
  4717. // NewResponses creates an object of type Responses if possible, returning an error if not.
  4718. func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) {
  4719. errors := make([]error, 0)
  4720. x := &Responses{}
  4721. m, ok := compiler.UnpackMap(in)
  4722. if !ok {
  4723. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4724. errors = append(errors, compiler.NewError(context, message))
  4725. } else {
  4726. allowedKeys := []string{}
  4727. allowedPatterns := []*regexp.Regexp{pattern2, pattern0}
  4728. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  4729. if len(invalidKeys) > 0 {
  4730. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  4731. errors = append(errors, compiler.NewError(context, message))
  4732. }
  4733. // repeated NamedResponseValue response_code = 1;
  4734. // MAP: ResponseValue ^([0-9]{3})$|^(default)$
  4735. x.ResponseCode = make([]*NamedResponseValue, 0)
  4736. for _, item := range m {
  4737. k, ok := compiler.StringValue(item.Key)
  4738. if ok {
  4739. v := item.Value
  4740. if pattern2.MatchString(k) {
  4741. pair := &NamedResponseValue{}
  4742. pair.Name = k
  4743. var err error
  4744. pair.Value, err = NewResponseValue(v, compiler.NewContext(k, context))
  4745. if err != nil {
  4746. errors = append(errors, err)
  4747. }
  4748. x.ResponseCode = append(x.ResponseCode, pair)
  4749. }
  4750. }
  4751. }
  4752. // repeated NamedAny vendor_extension = 2;
  4753. // MAP: Any ^x-
  4754. x.VendorExtension = make([]*NamedAny, 0)
  4755. for _, item := range m {
  4756. k, ok := compiler.StringValue(item.Key)
  4757. if ok {
  4758. v := item.Value
  4759. if strings.HasPrefix(k, "x-") {
  4760. pair := &NamedAny{}
  4761. pair.Name = k
  4762. result := &Any{}
  4763. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  4764. if handled {
  4765. if err != nil {
  4766. errors = append(errors, err)
  4767. } else {
  4768. bytes, _ := yaml.Marshal(v)
  4769. result.Yaml = string(bytes)
  4770. result.Value = resultFromExt
  4771. pair.Value = result
  4772. }
  4773. } else {
  4774. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  4775. if err != nil {
  4776. errors = append(errors, err)
  4777. }
  4778. }
  4779. x.VendorExtension = append(x.VendorExtension, pair)
  4780. }
  4781. }
  4782. }
  4783. }
  4784. return x, compiler.NewErrorGroupOrNil(errors)
  4785. }
  4786. // NewSchema creates an object of type Schema if possible, returning an error if not.
  4787. func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) {
  4788. errors := make([]error, 0)
  4789. x := &Schema{}
  4790. m, ok := compiler.UnpackMap(in)
  4791. if !ok {
  4792. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  4793. errors = append(errors, compiler.NewError(context, message))
  4794. } else {
  4795. allowedKeys := []string{"$ref", "additionalProperties", "allOf", "default", "description", "discriminator", "enum", "example", "exclusiveMaximum", "exclusiveMinimum", "externalDocs", "format", "items", "maxItems", "maxLength", "maxProperties", "maximum", "minItems", "minLength", "minProperties", "minimum", "multipleOf", "pattern", "properties", "readOnly", "required", "title", "type", "uniqueItems", "xml"}
  4796. allowedPatterns := []*regexp.Regexp{pattern0}
  4797. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  4798. if len(invalidKeys) > 0 {
  4799. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  4800. errors = append(errors, compiler.NewError(context, message))
  4801. }
  4802. // string _ref = 1;
  4803. v1 := compiler.MapValueForKey(m, "$ref")
  4804. if v1 != nil {
  4805. x.XRef, ok = v1.(string)
  4806. if !ok {
  4807. message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1)
  4808. errors = append(errors, compiler.NewError(context, message))
  4809. }
  4810. }
  4811. // string format = 2;
  4812. v2 := compiler.MapValueForKey(m, "format")
  4813. if v2 != nil {
  4814. x.Format, ok = v2.(string)
  4815. if !ok {
  4816. message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2)
  4817. errors = append(errors, compiler.NewError(context, message))
  4818. }
  4819. }
  4820. // string title = 3;
  4821. v3 := compiler.MapValueForKey(m, "title")
  4822. if v3 != nil {
  4823. x.Title, ok = v3.(string)
  4824. if !ok {
  4825. message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v3, v3)
  4826. errors = append(errors, compiler.NewError(context, message))
  4827. }
  4828. }
  4829. // string description = 4;
  4830. v4 := compiler.MapValueForKey(m, "description")
  4831. if v4 != nil {
  4832. x.Description, ok = v4.(string)
  4833. if !ok {
  4834. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4)
  4835. errors = append(errors, compiler.NewError(context, message))
  4836. }
  4837. }
  4838. // Any default = 5;
  4839. v5 := compiler.MapValueForKey(m, "default")
  4840. if v5 != nil {
  4841. var err error
  4842. x.Default, err = NewAny(v5, compiler.NewContext("default", context))
  4843. if err != nil {
  4844. errors = append(errors, err)
  4845. }
  4846. }
  4847. // float multiple_of = 6;
  4848. v6 := compiler.MapValueForKey(m, "multipleOf")
  4849. if v6 != nil {
  4850. switch v6 := v6.(type) {
  4851. case float64:
  4852. x.MultipleOf = v6
  4853. case float32:
  4854. x.MultipleOf = float64(v6)
  4855. case uint64:
  4856. x.MultipleOf = float64(v6)
  4857. case uint32:
  4858. x.MultipleOf = float64(v6)
  4859. case int64:
  4860. x.MultipleOf = float64(v6)
  4861. case int32:
  4862. x.MultipleOf = float64(v6)
  4863. case int:
  4864. x.MultipleOf = float64(v6)
  4865. default:
  4866. message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v6, v6)
  4867. errors = append(errors, compiler.NewError(context, message))
  4868. }
  4869. }
  4870. // float maximum = 7;
  4871. v7 := compiler.MapValueForKey(m, "maximum")
  4872. if v7 != nil {
  4873. switch v7 := v7.(type) {
  4874. case float64:
  4875. x.Maximum = v7
  4876. case float32:
  4877. x.Maximum = float64(v7)
  4878. case uint64:
  4879. x.Maximum = float64(v7)
  4880. case uint32:
  4881. x.Maximum = float64(v7)
  4882. case int64:
  4883. x.Maximum = float64(v7)
  4884. case int32:
  4885. x.Maximum = float64(v7)
  4886. case int:
  4887. x.Maximum = float64(v7)
  4888. default:
  4889. message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v7, v7)
  4890. errors = append(errors, compiler.NewError(context, message))
  4891. }
  4892. }
  4893. // bool exclusive_maximum = 8;
  4894. v8 := compiler.MapValueForKey(m, "exclusiveMaximum")
  4895. if v8 != nil {
  4896. x.ExclusiveMaximum, ok = v8.(bool)
  4897. if !ok {
  4898. message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v8, v8)
  4899. errors = append(errors, compiler.NewError(context, message))
  4900. }
  4901. }
  4902. // float minimum = 9;
  4903. v9 := compiler.MapValueForKey(m, "minimum")
  4904. if v9 != nil {
  4905. switch v9 := v9.(type) {
  4906. case float64:
  4907. x.Minimum = v9
  4908. case float32:
  4909. x.Minimum = float64(v9)
  4910. case uint64:
  4911. x.Minimum = float64(v9)
  4912. case uint32:
  4913. x.Minimum = float64(v9)
  4914. case int64:
  4915. x.Minimum = float64(v9)
  4916. case int32:
  4917. x.Minimum = float64(v9)
  4918. case int:
  4919. x.Minimum = float64(v9)
  4920. default:
  4921. message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9)
  4922. errors = append(errors, compiler.NewError(context, message))
  4923. }
  4924. }
  4925. // bool exclusive_minimum = 10;
  4926. v10 := compiler.MapValueForKey(m, "exclusiveMinimum")
  4927. if v10 != nil {
  4928. x.ExclusiveMinimum, ok = v10.(bool)
  4929. if !ok {
  4930. message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v10, v10)
  4931. errors = append(errors, compiler.NewError(context, message))
  4932. }
  4933. }
  4934. // int64 max_length = 11;
  4935. v11 := compiler.MapValueForKey(m, "maxLength")
  4936. if v11 != nil {
  4937. t, ok := v11.(int)
  4938. if ok {
  4939. x.MaxLength = int64(t)
  4940. } else {
  4941. message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v11, v11)
  4942. errors = append(errors, compiler.NewError(context, message))
  4943. }
  4944. }
  4945. // int64 min_length = 12;
  4946. v12 := compiler.MapValueForKey(m, "minLength")
  4947. if v12 != nil {
  4948. t, ok := v12.(int)
  4949. if ok {
  4950. x.MinLength = int64(t)
  4951. } else {
  4952. message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v12, v12)
  4953. errors = append(errors, compiler.NewError(context, message))
  4954. }
  4955. }
  4956. // string pattern = 13;
  4957. v13 := compiler.MapValueForKey(m, "pattern")
  4958. if v13 != nil {
  4959. x.Pattern, ok = v13.(string)
  4960. if !ok {
  4961. message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v13, v13)
  4962. errors = append(errors, compiler.NewError(context, message))
  4963. }
  4964. }
  4965. // int64 max_items = 14;
  4966. v14 := compiler.MapValueForKey(m, "maxItems")
  4967. if v14 != nil {
  4968. t, ok := v14.(int)
  4969. if ok {
  4970. x.MaxItems = int64(t)
  4971. } else {
  4972. message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v14, v14)
  4973. errors = append(errors, compiler.NewError(context, message))
  4974. }
  4975. }
  4976. // int64 min_items = 15;
  4977. v15 := compiler.MapValueForKey(m, "minItems")
  4978. if v15 != nil {
  4979. t, ok := v15.(int)
  4980. if ok {
  4981. x.MinItems = int64(t)
  4982. } else {
  4983. message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v15, v15)
  4984. errors = append(errors, compiler.NewError(context, message))
  4985. }
  4986. }
  4987. // bool unique_items = 16;
  4988. v16 := compiler.MapValueForKey(m, "uniqueItems")
  4989. if v16 != nil {
  4990. x.UniqueItems, ok = v16.(bool)
  4991. if !ok {
  4992. message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v16, v16)
  4993. errors = append(errors, compiler.NewError(context, message))
  4994. }
  4995. }
  4996. // int64 max_properties = 17;
  4997. v17 := compiler.MapValueForKey(m, "maxProperties")
  4998. if v17 != nil {
  4999. t, ok := v17.(int)
  5000. if ok {
  5001. x.MaxProperties = int64(t)
  5002. } else {
  5003. message := fmt.Sprintf("has unexpected value for maxProperties: %+v (%T)", v17, v17)
  5004. errors = append(errors, compiler.NewError(context, message))
  5005. }
  5006. }
  5007. // int64 min_properties = 18;
  5008. v18 := compiler.MapValueForKey(m, "minProperties")
  5009. if v18 != nil {
  5010. t, ok := v18.(int)
  5011. if ok {
  5012. x.MinProperties = int64(t)
  5013. } else {
  5014. message := fmt.Sprintf("has unexpected value for minProperties: %+v (%T)", v18, v18)
  5015. errors = append(errors, compiler.NewError(context, message))
  5016. }
  5017. }
  5018. // repeated string required = 19;
  5019. v19 := compiler.MapValueForKey(m, "required")
  5020. if v19 != nil {
  5021. v, ok := v19.([]interface{})
  5022. if ok {
  5023. x.Required = compiler.ConvertInterfaceArrayToStringArray(v)
  5024. } else {
  5025. message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v19, v19)
  5026. errors = append(errors, compiler.NewError(context, message))
  5027. }
  5028. }
  5029. // repeated Any enum = 20;
  5030. v20 := compiler.MapValueForKey(m, "enum")
  5031. if v20 != nil {
  5032. // repeated Any
  5033. x.Enum = make([]*Any, 0)
  5034. a, ok := v20.([]interface{})
  5035. if ok {
  5036. for _, item := range a {
  5037. y, err := NewAny(item, compiler.NewContext("enum", context))
  5038. if err != nil {
  5039. errors = append(errors, err)
  5040. }
  5041. x.Enum = append(x.Enum, y)
  5042. }
  5043. }
  5044. }
  5045. // AdditionalPropertiesItem additional_properties = 21;
  5046. v21 := compiler.MapValueForKey(m, "additionalProperties")
  5047. if v21 != nil {
  5048. var err error
  5049. x.AdditionalProperties, err = NewAdditionalPropertiesItem(v21, compiler.NewContext("additionalProperties", context))
  5050. if err != nil {
  5051. errors = append(errors, err)
  5052. }
  5053. }
  5054. // TypeItem type = 22;
  5055. v22 := compiler.MapValueForKey(m, "type")
  5056. if v22 != nil {
  5057. var err error
  5058. x.Type, err = NewTypeItem(v22, compiler.NewContext("type", context))
  5059. if err != nil {
  5060. errors = append(errors, err)
  5061. }
  5062. }
  5063. // ItemsItem items = 23;
  5064. v23 := compiler.MapValueForKey(m, "items")
  5065. if v23 != nil {
  5066. var err error
  5067. x.Items, err = NewItemsItem(v23, compiler.NewContext("items", context))
  5068. if err != nil {
  5069. errors = append(errors, err)
  5070. }
  5071. }
  5072. // repeated Schema all_of = 24;
  5073. v24 := compiler.MapValueForKey(m, "allOf")
  5074. if v24 != nil {
  5075. // repeated Schema
  5076. x.AllOf = make([]*Schema, 0)
  5077. a, ok := v24.([]interface{})
  5078. if ok {
  5079. for _, item := range a {
  5080. y, err := NewSchema(item, compiler.NewContext("allOf", context))
  5081. if err != nil {
  5082. errors = append(errors, err)
  5083. }
  5084. x.AllOf = append(x.AllOf, y)
  5085. }
  5086. }
  5087. }
  5088. // Properties properties = 25;
  5089. v25 := compiler.MapValueForKey(m, "properties")
  5090. if v25 != nil {
  5091. var err error
  5092. x.Properties, err = NewProperties(v25, compiler.NewContext("properties", context))
  5093. if err != nil {
  5094. errors = append(errors, err)
  5095. }
  5096. }
  5097. // string discriminator = 26;
  5098. v26 := compiler.MapValueForKey(m, "discriminator")
  5099. if v26 != nil {
  5100. x.Discriminator, ok = v26.(string)
  5101. if !ok {
  5102. message := fmt.Sprintf("has unexpected value for discriminator: %+v (%T)", v26, v26)
  5103. errors = append(errors, compiler.NewError(context, message))
  5104. }
  5105. }
  5106. // bool read_only = 27;
  5107. v27 := compiler.MapValueForKey(m, "readOnly")
  5108. if v27 != nil {
  5109. x.ReadOnly, ok = v27.(bool)
  5110. if !ok {
  5111. message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v27, v27)
  5112. errors = append(errors, compiler.NewError(context, message))
  5113. }
  5114. }
  5115. // Xml xml = 28;
  5116. v28 := compiler.MapValueForKey(m, "xml")
  5117. if v28 != nil {
  5118. var err error
  5119. x.Xml, err = NewXml(v28, compiler.NewContext("xml", context))
  5120. if err != nil {
  5121. errors = append(errors, err)
  5122. }
  5123. }
  5124. // ExternalDocs external_docs = 29;
  5125. v29 := compiler.MapValueForKey(m, "externalDocs")
  5126. if v29 != nil {
  5127. var err error
  5128. x.ExternalDocs, err = NewExternalDocs(v29, compiler.NewContext("externalDocs", context))
  5129. if err != nil {
  5130. errors = append(errors, err)
  5131. }
  5132. }
  5133. // Any example = 30;
  5134. v30 := compiler.MapValueForKey(m, "example")
  5135. if v30 != nil {
  5136. var err error
  5137. x.Example, err = NewAny(v30, compiler.NewContext("example", context))
  5138. if err != nil {
  5139. errors = append(errors, err)
  5140. }
  5141. }
  5142. // repeated NamedAny vendor_extension = 31;
  5143. // MAP: Any ^x-
  5144. x.VendorExtension = make([]*NamedAny, 0)
  5145. for _, item := range m {
  5146. k, ok := compiler.StringValue(item.Key)
  5147. if ok {
  5148. v := item.Value
  5149. if strings.HasPrefix(k, "x-") {
  5150. pair := &NamedAny{}
  5151. pair.Name = k
  5152. result := &Any{}
  5153. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  5154. if handled {
  5155. if err != nil {
  5156. errors = append(errors, err)
  5157. } else {
  5158. bytes, _ := yaml.Marshal(v)
  5159. result.Yaml = string(bytes)
  5160. result.Value = resultFromExt
  5161. pair.Value = result
  5162. }
  5163. } else {
  5164. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  5165. if err != nil {
  5166. errors = append(errors, err)
  5167. }
  5168. }
  5169. x.VendorExtension = append(x.VendorExtension, pair)
  5170. }
  5171. }
  5172. }
  5173. }
  5174. return x, compiler.NewErrorGroupOrNil(errors)
  5175. }
  5176. // NewSchemaItem creates an object of type SchemaItem if possible, returning an error if not.
  5177. func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, error) {
  5178. errors := make([]error, 0)
  5179. x := &SchemaItem{}
  5180. matched := false
  5181. // Schema schema = 1;
  5182. {
  5183. m, ok := compiler.UnpackMap(in)
  5184. if ok {
  5185. // errors might be ok here, they mean we just don't have the right subtype
  5186. t, matchingError := NewSchema(m, compiler.NewContext("schema", context))
  5187. if matchingError == nil {
  5188. x.Oneof = &SchemaItem_Schema{Schema: t}
  5189. matched = true
  5190. } else {
  5191. errors = append(errors, matchingError)
  5192. }
  5193. }
  5194. }
  5195. // FileSchema file_schema = 2;
  5196. {
  5197. m, ok := compiler.UnpackMap(in)
  5198. if ok {
  5199. // errors might be ok here, they mean we just don't have the right subtype
  5200. t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", context))
  5201. if matchingError == nil {
  5202. x.Oneof = &SchemaItem_FileSchema{FileSchema: t}
  5203. matched = true
  5204. } else {
  5205. errors = append(errors, matchingError)
  5206. }
  5207. }
  5208. }
  5209. if matched {
  5210. // since the oneof matched one of its possibilities, discard any matching errors
  5211. errors = make([]error, 0)
  5212. }
  5213. return x, compiler.NewErrorGroupOrNil(errors)
  5214. }
  5215. // NewSecurityDefinitions creates an object of type SecurityDefinitions if possible, returning an error if not.
  5216. func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*SecurityDefinitions, error) {
  5217. errors := make([]error, 0)
  5218. x := &SecurityDefinitions{}
  5219. m, ok := compiler.UnpackMap(in)
  5220. if !ok {
  5221. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  5222. errors = append(errors, compiler.NewError(context, message))
  5223. } else {
  5224. // repeated NamedSecurityDefinitionsItem additional_properties = 1;
  5225. // MAP: SecurityDefinitionsItem
  5226. x.AdditionalProperties = make([]*NamedSecurityDefinitionsItem, 0)
  5227. for _, item := range m {
  5228. k, ok := compiler.StringValue(item.Key)
  5229. if ok {
  5230. v := item.Value
  5231. pair := &NamedSecurityDefinitionsItem{}
  5232. pair.Name = k
  5233. var err error
  5234. pair.Value, err = NewSecurityDefinitionsItem(v, compiler.NewContext(k, context))
  5235. if err != nil {
  5236. errors = append(errors, err)
  5237. }
  5238. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  5239. }
  5240. }
  5241. }
  5242. return x, compiler.NewErrorGroupOrNil(errors)
  5243. }
  5244. // NewSecurityDefinitionsItem creates an object of type SecurityDefinitionsItem if possible, returning an error if not.
  5245. func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*SecurityDefinitionsItem, error) {
  5246. errors := make([]error, 0)
  5247. x := &SecurityDefinitionsItem{}
  5248. matched := false
  5249. // BasicAuthenticationSecurity basic_authentication_security = 1;
  5250. {
  5251. m, ok := compiler.UnpackMap(in)
  5252. if ok {
  5253. // errors might be ok here, they mean we just don't have the right subtype
  5254. t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", context))
  5255. if matchingError == nil {
  5256. x.Oneof = &SecurityDefinitionsItem_BasicAuthenticationSecurity{BasicAuthenticationSecurity: t}
  5257. matched = true
  5258. } else {
  5259. errors = append(errors, matchingError)
  5260. }
  5261. }
  5262. }
  5263. // ApiKeySecurity api_key_security = 2;
  5264. {
  5265. m, ok := compiler.UnpackMap(in)
  5266. if ok {
  5267. // errors might be ok here, they mean we just don't have the right subtype
  5268. t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", context))
  5269. if matchingError == nil {
  5270. x.Oneof = &SecurityDefinitionsItem_ApiKeySecurity{ApiKeySecurity: t}
  5271. matched = true
  5272. } else {
  5273. errors = append(errors, matchingError)
  5274. }
  5275. }
  5276. }
  5277. // Oauth2ImplicitSecurity oauth2_implicit_security = 3;
  5278. {
  5279. m, ok := compiler.UnpackMap(in)
  5280. if ok {
  5281. // errors might be ok here, they mean we just don't have the right subtype
  5282. t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", context))
  5283. if matchingError == nil {
  5284. x.Oneof = &SecurityDefinitionsItem_Oauth2ImplicitSecurity{Oauth2ImplicitSecurity: t}
  5285. matched = true
  5286. } else {
  5287. errors = append(errors, matchingError)
  5288. }
  5289. }
  5290. }
  5291. // Oauth2PasswordSecurity oauth2_password_security = 4;
  5292. {
  5293. m, ok := compiler.UnpackMap(in)
  5294. if ok {
  5295. // errors might be ok here, they mean we just don't have the right subtype
  5296. t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", context))
  5297. if matchingError == nil {
  5298. x.Oneof = &SecurityDefinitionsItem_Oauth2PasswordSecurity{Oauth2PasswordSecurity: t}
  5299. matched = true
  5300. } else {
  5301. errors = append(errors, matchingError)
  5302. }
  5303. }
  5304. }
  5305. // Oauth2ApplicationSecurity oauth2_application_security = 5;
  5306. {
  5307. m, ok := compiler.UnpackMap(in)
  5308. if ok {
  5309. // errors might be ok here, they mean we just don't have the right subtype
  5310. t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", context))
  5311. if matchingError == nil {
  5312. x.Oneof = &SecurityDefinitionsItem_Oauth2ApplicationSecurity{Oauth2ApplicationSecurity: t}
  5313. matched = true
  5314. } else {
  5315. errors = append(errors, matchingError)
  5316. }
  5317. }
  5318. }
  5319. // Oauth2AccessCodeSecurity oauth2_access_code_security = 6;
  5320. {
  5321. m, ok := compiler.UnpackMap(in)
  5322. if ok {
  5323. // errors might be ok here, they mean we just don't have the right subtype
  5324. t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", context))
  5325. if matchingError == nil {
  5326. x.Oneof = &SecurityDefinitionsItem_Oauth2AccessCodeSecurity{Oauth2AccessCodeSecurity: t}
  5327. matched = true
  5328. } else {
  5329. errors = append(errors, matchingError)
  5330. }
  5331. }
  5332. }
  5333. if matched {
  5334. // since the oneof matched one of its possibilities, discard any matching errors
  5335. errors = make([]error, 0)
  5336. }
  5337. return x, compiler.NewErrorGroupOrNil(errors)
  5338. }
  5339. // NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not.
  5340. func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) {
  5341. errors := make([]error, 0)
  5342. x := &SecurityRequirement{}
  5343. m, ok := compiler.UnpackMap(in)
  5344. if !ok {
  5345. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  5346. errors = append(errors, compiler.NewError(context, message))
  5347. } else {
  5348. // repeated NamedStringArray additional_properties = 1;
  5349. // MAP: StringArray
  5350. x.AdditionalProperties = make([]*NamedStringArray, 0)
  5351. for _, item := range m {
  5352. k, ok := compiler.StringValue(item.Key)
  5353. if ok {
  5354. v := item.Value
  5355. pair := &NamedStringArray{}
  5356. pair.Name = k
  5357. var err error
  5358. pair.Value, err = NewStringArray(v, compiler.NewContext(k, context))
  5359. if err != nil {
  5360. errors = append(errors, err)
  5361. }
  5362. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  5363. }
  5364. }
  5365. }
  5366. return x, compiler.NewErrorGroupOrNil(errors)
  5367. }
  5368. // NewStringArray creates an object of type StringArray if possible, returning an error if not.
  5369. func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) {
  5370. errors := make([]error, 0)
  5371. x := &StringArray{}
  5372. a, ok := in.([]interface{})
  5373. if !ok {
  5374. message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in)
  5375. errors = append(errors, compiler.NewError(context, message))
  5376. } else {
  5377. x.Value = make([]string, 0)
  5378. for _, s := range a {
  5379. x.Value = append(x.Value, s.(string))
  5380. }
  5381. }
  5382. return x, compiler.NewErrorGroupOrNil(errors)
  5383. }
  5384. // NewTag creates an object of type Tag if possible, returning an error if not.
  5385. func NewTag(in interface{}, context *compiler.Context) (*Tag, error) {
  5386. errors := make([]error, 0)
  5387. x := &Tag{}
  5388. m, ok := compiler.UnpackMap(in)
  5389. if !ok {
  5390. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  5391. errors = append(errors, compiler.NewError(context, message))
  5392. } else {
  5393. requiredKeys := []string{"name"}
  5394. missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
  5395. if len(missingKeys) > 0 {
  5396. message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
  5397. errors = append(errors, compiler.NewError(context, message))
  5398. }
  5399. allowedKeys := []string{"description", "externalDocs", "name"}
  5400. allowedPatterns := []*regexp.Regexp{pattern0}
  5401. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  5402. if len(invalidKeys) > 0 {
  5403. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  5404. errors = append(errors, compiler.NewError(context, message))
  5405. }
  5406. // string name = 1;
  5407. v1 := compiler.MapValueForKey(m, "name")
  5408. if v1 != nil {
  5409. x.Name, ok = v1.(string)
  5410. if !ok {
  5411. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  5412. errors = append(errors, compiler.NewError(context, message))
  5413. }
  5414. }
  5415. // string description = 2;
  5416. v2 := compiler.MapValueForKey(m, "description")
  5417. if v2 != nil {
  5418. x.Description, ok = v2.(string)
  5419. if !ok {
  5420. message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
  5421. errors = append(errors, compiler.NewError(context, message))
  5422. }
  5423. }
  5424. // ExternalDocs external_docs = 3;
  5425. v3 := compiler.MapValueForKey(m, "externalDocs")
  5426. if v3 != nil {
  5427. var err error
  5428. x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", context))
  5429. if err != nil {
  5430. errors = append(errors, err)
  5431. }
  5432. }
  5433. // repeated NamedAny vendor_extension = 4;
  5434. // MAP: Any ^x-
  5435. x.VendorExtension = make([]*NamedAny, 0)
  5436. for _, item := range m {
  5437. k, ok := compiler.StringValue(item.Key)
  5438. if ok {
  5439. v := item.Value
  5440. if strings.HasPrefix(k, "x-") {
  5441. pair := &NamedAny{}
  5442. pair.Name = k
  5443. result := &Any{}
  5444. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  5445. if handled {
  5446. if err != nil {
  5447. errors = append(errors, err)
  5448. } else {
  5449. bytes, _ := yaml.Marshal(v)
  5450. result.Yaml = string(bytes)
  5451. result.Value = resultFromExt
  5452. pair.Value = result
  5453. }
  5454. } else {
  5455. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  5456. if err != nil {
  5457. errors = append(errors, err)
  5458. }
  5459. }
  5460. x.VendorExtension = append(x.VendorExtension, pair)
  5461. }
  5462. }
  5463. }
  5464. }
  5465. return x, compiler.NewErrorGroupOrNil(errors)
  5466. }
  5467. // NewTypeItem creates an object of type TypeItem if possible, returning an error if not.
  5468. func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) {
  5469. errors := make([]error, 0)
  5470. x := &TypeItem{}
  5471. switch in := in.(type) {
  5472. case string:
  5473. x.Value = make([]string, 0)
  5474. x.Value = append(x.Value, in)
  5475. case []interface{}:
  5476. x.Value = make([]string, 0)
  5477. for _, v := range in {
  5478. value, ok := v.(string)
  5479. if ok {
  5480. x.Value = append(x.Value, value)
  5481. } else {
  5482. message := fmt.Sprintf("has unexpected value for string array element: %+v (%T)", value, value)
  5483. errors = append(errors, compiler.NewError(context, message))
  5484. }
  5485. }
  5486. default:
  5487. message := fmt.Sprintf("has unexpected value for string array: %+v (%T)", in, in)
  5488. errors = append(errors, compiler.NewError(context, message))
  5489. }
  5490. return x, compiler.NewErrorGroupOrNil(errors)
  5491. }
  5492. // NewVendorExtension creates an object of type VendorExtension if possible, returning an error if not.
  5493. func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExtension, error) {
  5494. errors := make([]error, 0)
  5495. x := &VendorExtension{}
  5496. m, ok := compiler.UnpackMap(in)
  5497. if !ok {
  5498. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  5499. errors = append(errors, compiler.NewError(context, message))
  5500. } else {
  5501. // repeated NamedAny additional_properties = 1;
  5502. // MAP: Any
  5503. x.AdditionalProperties = make([]*NamedAny, 0)
  5504. for _, item := range m {
  5505. k, ok := compiler.StringValue(item.Key)
  5506. if ok {
  5507. v := item.Value
  5508. pair := &NamedAny{}
  5509. pair.Name = k
  5510. result := &Any{}
  5511. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  5512. if handled {
  5513. if err != nil {
  5514. errors = append(errors, err)
  5515. } else {
  5516. bytes, _ := yaml.Marshal(v)
  5517. result.Yaml = string(bytes)
  5518. result.Value = resultFromExt
  5519. pair.Value = result
  5520. }
  5521. } else {
  5522. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  5523. if err != nil {
  5524. errors = append(errors, err)
  5525. }
  5526. }
  5527. x.AdditionalProperties = append(x.AdditionalProperties, pair)
  5528. }
  5529. }
  5530. }
  5531. return x, compiler.NewErrorGroupOrNil(errors)
  5532. }
  5533. // NewXml creates an object of type Xml if possible, returning an error if not.
  5534. func NewXml(in interface{}, context *compiler.Context) (*Xml, error) {
  5535. errors := make([]error, 0)
  5536. x := &Xml{}
  5537. m, ok := compiler.UnpackMap(in)
  5538. if !ok {
  5539. message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
  5540. errors = append(errors, compiler.NewError(context, message))
  5541. } else {
  5542. allowedKeys := []string{"attribute", "name", "namespace", "prefix", "wrapped"}
  5543. allowedPatterns := []*regexp.Regexp{pattern0}
  5544. invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
  5545. if len(invalidKeys) > 0 {
  5546. message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
  5547. errors = append(errors, compiler.NewError(context, message))
  5548. }
  5549. // string name = 1;
  5550. v1 := compiler.MapValueForKey(m, "name")
  5551. if v1 != nil {
  5552. x.Name, ok = v1.(string)
  5553. if !ok {
  5554. message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
  5555. errors = append(errors, compiler.NewError(context, message))
  5556. }
  5557. }
  5558. // string namespace = 2;
  5559. v2 := compiler.MapValueForKey(m, "namespace")
  5560. if v2 != nil {
  5561. x.Namespace, ok = v2.(string)
  5562. if !ok {
  5563. message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2)
  5564. errors = append(errors, compiler.NewError(context, message))
  5565. }
  5566. }
  5567. // string prefix = 3;
  5568. v3 := compiler.MapValueForKey(m, "prefix")
  5569. if v3 != nil {
  5570. x.Prefix, ok = v3.(string)
  5571. if !ok {
  5572. message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3)
  5573. errors = append(errors, compiler.NewError(context, message))
  5574. }
  5575. }
  5576. // bool attribute = 4;
  5577. v4 := compiler.MapValueForKey(m, "attribute")
  5578. if v4 != nil {
  5579. x.Attribute, ok = v4.(bool)
  5580. if !ok {
  5581. message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4)
  5582. errors = append(errors, compiler.NewError(context, message))
  5583. }
  5584. }
  5585. // bool wrapped = 5;
  5586. v5 := compiler.MapValueForKey(m, "wrapped")
  5587. if v5 != nil {
  5588. x.Wrapped, ok = v5.(bool)
  5589. if !ok {
  5590. message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5)
  5591. errors = append(errors, compiler.NewError(context, message))
  5592. }
  5593. }
  5594. // repeated NamedAny vendor_extension = 6;
  5595. // MAP: Any ^x-
  5596. x.VendorExtension = make([]*NamedAny, 0)
  5597. for _, item := range m {
  5598. k, ok := compiler.StringValue(item.Key)
  5599. if ok {
  5600. v := item.Value
  5601. if strings.HasPrefix(k, "x-") {
  5602. pair := &NamedAny{}
  5603. pair.Name = k
  5604. result := &Any{}
  5605. handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
  5606. if handled {
  5607. if err != nil {
  5608. errors = append(errors, err)
  5609. } else {
  5610. bytes, _ := yaml.Marshal(v)
  5611. result.Yaml = string(bytes)
  5612. result.Value = resultFromExt
  5613. pair.Value = result
  5614. }
  5615. } else {
  5616. pair.Value, err = NewAny(v, compiler.NewContext(k, context))
  5617. if err != nil {
  5618. errors = append(errors, err)
  5619. }
  5620. }
  5621. x.VendorExtension = append(x.VendorExtension, pair)
  5622. }
  5623. }
  5624. }
  5625. }
  5626. return x, compiler.NewErrorGroupOrNil(errors)
  5627. }
  5628. // ResolveReferences resolves references found inside AdditionalPropertiesItem objects.
  5629. func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, error) {
  5630. errors := make([]error, 0)
  5631. {
  5632. p, ok := m.Oneof.(*AdditionalPropertiesItem_Schema)
  5633. if ok {
  5634. _, err := p.Schema.ResolveReferences(root)
  5635. if err != nil {
  5636. return nil, err
  5637. }
  5638. }
  5639. }
  5640. return nil, compiler.NewErrorGroupOrNil(errors)
  5641. }
  5642. // ResolveReferences resolves references found inside Any objects.
  5643. func (m *Any) ResolveReferences(root string) (interface{}, error) {
  5644. errors := make([]error, 0)
  5645. return nil, compiler.NewErrorGroupOrNil(errors)
  5646. }
  5647. // ResolveReferences resolves references found inside ApiKeySecurity objects.
  5648. func (m *ApiKeySecurity) ResolveReferences(root string) (interface{}, error) {
  5649. errors := make([]error, 0)
  5650. for _, item := range m.VendorExtension {
  5651. if item != nil {
  5652. _, err := item.ResolveReferences(root)
  5653. if err != nil {
  5654. errors = append(errors, err)
  5655. }
  5656. }
  5657. }
  5658. return nil, compiler.NewErrorGroupOrNil(errors)
  5659. }
  5660. // ResolveReferences resolves references found inside BasicAuthenticationSecurity objects.
  5661. func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{}, error) {
  5662. errors := make([]error, 0)
  5663. for _, item := range m.VendorExtension {
  5664. if item != nil {
  5665. _, err := item.ResolveReferences(root)
  5666. if err != nil {
  5667. errors = append(errors, err)
  5668. }
  5669. }
  5670. }
  5671. return nil, compiler.NewErrorGroupOrNil(errors)
  5672. }
  5673. // ResolveReferences resolves references found inside BodyParameter objects.
  5674. func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) {
  5675. errors := make([]error, 0)
  5676. if m.Schema != nil {
  5677. _, err := m.Schema.ResolveReferences(root)
  5678. if err != nil {
  5679. errors = append(errors, err)
  5680. }
  5681. }
  5682. for _, item := range m.VendorExtension {
  5683. if item != nil {
  5684. _, err := item.ResolveReferences(root)
  5685. if err != nil {
  5686. errors = append(errors, err)
  5687. }
  5688. }
  5689. }
  5690. return nil, compiler.NewErrorGroupOrNil(errors)
  5691. }
  5692. // ResolveReferences resolves references found inside Contact objects.
  5693. func (m *Contact) ResolveReferences(root string) (interface{}, error) {
  5694. errors := make([]error, 0)
  5695. for _, item := range m.VendorExtension {
  5696. if item != nil {
  5697. _, err := item.ResolveReferences(root)
  5698. if err != nil {
  5699. errors = append(errors, err)
  5700. }
  5701. }
  5702. }
  5703. return nil, compiler.NewErrorGroupOrNil(errors)
  5704. }
  5705. // ResolveReferences resolves references found inside Default objects.
  5706. func (m *Default) ResolveReferences(root string) (interface{}, error) {
  5707. errors := make([]error, 0)
  5708. for _, item := range m.AdditionalProperties {
  5709. if item != nil {
  5710. _, err := item.ResolveReferences(root)
  5711. if err != nil {
  5712. errors = append(errors, err)
  5713. }
  5714. }
  5715. }
  5716. return nil, compiler.NewErrorGroupOrNil(errors)
  5717. }
  5718. // ResolveReferences resolves references found inside Definitions objects.
  5719. func (m *Definitions) ResolveReferences(root string) (interface{}, error) {
  5720. errors := make([]error, 0)
  5721. for _, item := range m.AdditionalProperties {
  5722. if item != nil {
  5723. _, err := item.ResolveReferences(root)
  5724. if err != nil {
  5725. errors = append(errors, err)
  5726. }
  5727. }
  5728. }
  5729. return nil, compiler.NewErrorGroupOrNil(errors)
  5730. }
  5731. // ResolveReferences resolves references found inside Document objects.
  5732. func (m *Document) ResolveReferences(root string) (interface{}, error) {
  5733. errors := make([]error, 0)
  5734. if m.Info != nil {
  5735. _, err := m.Info.ResolveReferences(root)
  5736. if err != nil {
  5737. errors = append(errors, err)
  5738. }
  5739. }
  5740. if m.Paths != nil {
  5741. _, err := m.Paths.ResolveReferences(root)
  5742. if err != nil {
  5743. errors = append(errors, err)
  5744. }
  5745. }
  5746. if m.Definitions != nil {
  5747. _, err := m.Definitions.ResolveReferences(root)
  5748. if err != nil {
  5749. errors = append(errors, err)
  5750. }
  5751. }
  5752. if m.Parameters != nil {
  5753. _, err := m.Parameters.ResolveReferences(root)
  5754. if err != nil {
  5755. errors = append(errors, err)
  5756. }
  5757. }
  5758. if m.Responses != nil {
  5759. _, err := m.Responses.ResolveReferences(root)
  5760. if err != nil {
  5761. errors = append(errors, err)
  5762. }
  5763. }
  5764. for _, item := range m.Security {
  5765. if item != nil {
  5766. _, err := item.ResolveReferences(root)
  5767. if err != nil {
  5768. errors = append(errors, err)
  5769. }
  5770. }
  5771. }
  5772. if m.SecurityDefinitions != nil {
  5773. _, err := m.SecurityDefinitions.ResolveReferences(root)
  5774. if err != nil {
  5775. errors = append(errors, err)
  5776. }
  5777. }
  5778. for _, item := range m.Tags {
  5779. if item != nil {
  5780. _, err := item.ResolveReferences(root)
  5781. if err != nil {
  5782. errors = append(errors, err)
  5783. }
  5784. }
  5785. }
  5786. if m.ExternalDocs != nil {
  5787. _, err := m.ExternalDocs.ResolveReferences(root)
  5788. if err != nil {
  5789. errors = append(errors, err)
  5790. }
  5791. }
  5792. for _, item := range m.VendorExtension {
  5793. if item != nil {
  5794. _, err := item.ResolveReferences(root)
  5795. if err != nil {
  5796. errors = append(errors, err)
  5797. }
  5798. }
  5799. }
  5800. return nil, compiler.NewErrorGroupOrNil(errors)
  5801. }
  5802. // ResolveReferences resolves references found inside Examples objects.
  5803. func (m *Examples) ResolveReferences(root string) (interface{}, error) {
  5804. errors := make([]error, 0)
  5805. for _, item := range m.AdditionalProperties {
  5806. if item != nil {
  5807. _, err := item.ResolveReferences(root)
  5808. if err != nil {
  5809. errors = append(errors, err)
  5810. }
  5811. }
  5812. }
  5813. return nil, compiler.NewErrorGroupOrNil(errors)
  5814. }
  5815. // ResolveReferences resolves references found inside ExternalDocs objects.
  5816. func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) {
  5817. errors := make([]error, 0)
  5818. for _, item := range m.VendorExtension {
  5819. if item != nil {
  5820. _, err := item.ResolveReferences(root)
  5821. if err != nil {
  5822. errors = append(errors, err)
  5823. }
  5824. }
  5825. }
  5826. return nil, compiler.NewErrorGroupOrNil(errors)
  5827. }
  5828. // ResolveReferences resolves references found inside FileSchema objects.
  5829. func (m *FileSchema) ResolveReferences(root string) (interface{}, error) {
  5830. errors := make([]error, 0)
  5831. if m.Default != nil {
  5832. _, err := m.Default.ResolveReferences(root)
  5833. if err != nil {
  5834. errors = append(errors, err)
  5835. }
  5836. }
  5837. if m.ExternalDocs != nil {
  5838. _, err := m.ExternalDocs.ResolveReferences(root)
  5839. if err != nil {
  5840. errors = append(errors, err)
  5841. }
  5842. }
  5843. if m.Example != nil {
  5844. _, err := m.Example.ResolveReferences(root)
  5845. if err != nil {
  5846. errors = append(errors, err)
  5847. }
  5848. }
  5849. for _, item := range m.VendorExtension {
  5850. if item != nil {
  5851. _, err := item.ResolveReferences(root)
  5852. if err != nil {
  5853. errors = append(errors, err)
  5854. }
  5855. }
  5856. }
  5857. return nil, compiler.NewErrorGroupOrNil(errors)
  5858. }
  5859. // ResolveReferences resolves references found inside FormDataParameterSubSchema objects.
  5860. func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{}, error) {
  5861. errors := make([]error, 0)
  5862. if m.Items != nil {
  5863. _, err := m.Items.ResolveReferences(root)
  5864. if err != nil {
  5865. errors = append(errors, err)
  5866. }
  5867. }
  5868. if m.Default != nil {
  5869. _, err := m.Default.ResolveReferences(root)
  5870. if err != nil {
  5871. errors = append(errors, err)
  5872. }
  5873. }
  5874. for _, item := range m.Enum {
  5875. if item != nil {
  5876. _, err := item.ResolveReferences(root)
  5877. if err != nil {
  5878. errors = append(errors, err)
  5879. }
  5880. }
  5881. }
  5882. for _, item := range m.VendorExtension {
  5883. if item != nil {
  5884. _, err := item.ResolveReferences(root)
  5885. if err != nil {
  5886. errors = append(errors, err)
  5887. }
  5888. }
  5889. }
  5890. return nil, compiler.NewErrorGroupOrNil(errors)
  5891. }
  5892. // ResolveReferences resolves references found inside Header objects.
  5893. func (m *Header) ResolveReferences(root string) (interface{}, error) {
  5894. errors := make([]error, 0)
  5895. if m.Items != nil {
  5896. _, err := m.Items.ResolveReferences(root)
  5897. if err != nil {
  5898. errors = append(errors, err)
  5899. }
  5900. }
  5901. if m.Default != nil {
  5902. _, err := m.Default.ResolveReferences(root)
  5903. if err != nil {
  5904. errors = append(errors, err)
  5905. }
  5906. }
  5907. for _, item := range m.Enum {
  5908. if item != nil {
  5909. _, err := item.ResolveReferences(root)
  5910. if err != nil {
  5911. errors = append(errors, err)
  5912. }
  5913. }
  5914. }
  5915. for _, item := range m.VendorExtension {
  5916. if item != nil {
  5917. _, err := item.ResolveReferences(root)
  5918. if err != nil {
  5919. errors = append(errors, err)
  5920. }
  5921. }
  5922. }
  5923. return nil, compiler.NewErrorGroupOrNil(errors)
  5924. }
  5925. // ResolveReferences resolves references found inside HeaderParameterSubSchema objects.
  5926. func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, error) {
  5927. errors := make([]error, 0)
  5928. if m.Items != nil {
  5929. _, err := m.Items.ResolveReferences(root)
  5930. if err != nil {
  5931. errors = append(errors, err)
  5932. }
  5933. }
  5934. if m.Default != nil {
  5935. _, err := m.Default.ResolveReferences(root)
  5936. if err != nil {
  5937. errors = append(errors, err)
  5938. }
  5939. }
  5940. for _, item := range m.Enum {
  5941. if item != nil {
  5942. _, err := item.ResolveReferences(root)
  5943. if err != nil {
  5944. errors = append(errors, err)
  5945. }
  5946. }
  5947. }
  5948. for _, item := range m.VendorExtension {
  5949. if item != nil {
  5950. _, err := item.ResolveReferences(root)
  5951. if err != nil {
  5952. errors = append(errors, err)
  5953. }
  5954. }
  5955. }
  5956. return nil, compiler.NewErrorGroupOrNil(errors)
  5957. }
  5958. // ResolveReferences resolves references found inside Headers objects.
  5959. func (m *Headers) ResolveReferences(root string) (interface{}, error) {
  5960. errors := make([]error, 0)
  5961. for _, item := range m.AdditionalProperties {
  5962. if item != nil {
  5963. _, err := item.ResolveReferences(root)
  5964. if err != nil {
  5965. errors = append(errors, err)
  5966. }
  5967. }
  5968. }
  5969. return nil, compiler.NewErrorGroupOrNil(errors)
  5970. }
  5971. // ResolveReferences resolves references found inside Info objects.
  5972. func (m *Info) ResolveReferences(root string) (interface{}, error) {
  5973. errors := make([]error, 0)
  5974. if m.Contact != nil {
  5975. _, err := m.Contact.ResolveReferences(root)
  5976. if err != nil {
  5977. errors = append(errors, err)
  5978. }
  5979. }
  5980. if m.License != nil {
  5981. _, err := m.License.ResolveReferences(root)
  5982. if err != nil {
  5983. errors = append(errors, err)
  5984. }
  5985. }
  5986. for _, item := range m.VendorExtension {
  5987. if item != nil {
  5988. _, err := item.ResolveReferences(root)
  5989. if err != nil {
  5990. errors = append(errors, err)
  5991. }
  5992. }
  5993. }
  5994. return nil, compiler.NewErrorGroupOrNil(errors)
  5995. }
  5996. // ResolveReferences resolves references found inside ItemsItem objects.
  5997. func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) {
  5998. errors := make([]error, 0)
  5999. for _, item := range m.Schema {
  6000. if item != nil {
  6001. _, err := item.ResolveReferences(root)
  6002. if err != nil {
  6003. errors = append(errors, err)
  6004. }
  6005. }
  6006. }
  6007. return nil, compiler.NewErrorGroupOrNil(errors)
  6008. }
  6009. // ResolveReferences resolves references found inside JsonReference objects.
  6010. func (m *JsonReference) ResolveReferences(root string) (interface{}, error) {
  6011. errors := make([]error, 0)
  6012. if m.XRef != "" {
  6013. info, err := compiler.ReadInfoForRef(root, m.XRef)
  6014. if err != nil {
  6015. return nil, err
  6016. }
  6017. if info != nil {
  6018. replacement, err := NewJsonReference(info, nil)
  6019. if err == nil {
  6020. *m = *replacement
  6021. return m.ResolveReferences(root)
  6022. }
  6023. }
  6024. return info, nil
  6025. }
  6026. return nil, compiler.NewErrorGroupOrNil(errors)
  6027. }
  6028. // ResolveReferences resolves references found inside License objects.
  6029. func (m *License) ResolveReferences(root string) (interface{}, error) {
  6030. errors := make([]error, 0)
  6031. for _, item := range m.VendorExtension {
  6032. if item != nil {
  6033. _, err := item.ResolveReferences(root)
  6034. if err != nil {
  6035. errors = append(errors, err)
  6036. }
  6037. }
  6038. }
  6039. return nil, compiler.NewErrorGroupOrNil(errors)
  6040. }
  6041. // ResolveReferences resolves references found inside NamedAny objects.
  6042. func (m *NamedAny) ResolveReferences(root string) (interface{}, error) {
  6043. errors := make([]error, 0)
  6044. if m.Value != nil {
  6045. _, err := m.Value.ResolveReferences(root)
  6046. if err != nil {
  6047. errors = append(errors, err)
  6048. }
  6049. }
  6050. return nil, compiler.NewErrorGroupOrNil(errors)
  6051. }
  6052. // ResolveReferences resolves references found inside NamedHeader objects.
  6053. func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) {
  6054. errors := make([]error, 0)
  6055. if m.Value != nil {
  6056. _, err := m.Value.ResolveReferences(root)
  6057. if err != nil {
  6058. errors = append(errors, err)
  6059. }
  6060. }
  6061. return nil, compiler.NewErrorGroupOrNil(errors)
  6062. }
  6063. // ResolveReferences resolves references found inside NamedParameter objects.
  6064. func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) {
  6065. errors := make([]error, 0)
  6066. if m.Value != nil {
  6067. _, err := m.Value.ResolveReferences(root)
  6068. if err != nil {
  6069. errors = append(errors, err)
  6070. }
  6071. }
  6072. return nil, compiler.NewErrorGroupOrNil(errors)
  6073. }
  6074. // ResolveReferences resolves references found inside NamedPathItem objects.
  6075. func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) {
  6076. errors := make([]error, 0)
  6077. if m.Value != nil {
  6078. _, err := m.Value.ResolveReferences(root)
  6079. if err != nil {
  6080. errors = append(errors, err)
  6081. }
  6082. }
  6083. return nil, compiler.NewErrorGroupOrNil(errors)
  6084. }
  6085. // ResolveReferences resolves references found inside NamedResponse objects.
  6086. func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) {
  6087. errors := make([]error, 0)
  6088. if m.Value != nil {
  6089. _, err := m.Value.ResolveReferences(root)
  6090. if err != nil {
  6091. errors = append(errors, err)
  6092. }
  6093. }
  6094. return nil, compiler.NewErrorGroupOrNil(errors)
  6095. }
  6096. // ResolveReferences resolves references found inside NamedResponseValue objects.
  6097. func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) {
  6098. errors := make([]error, 0)
  6099. if m.Value != nil {
  6100. _, err := m.Value.ResolveReferences(root)
  6101. if err != nil {
  6102. errors = append(errors, err)
  6103. }
  6104. }
  6105. return nil, compiler.NewErrorGroupOrNil(errors)
  6106. }
  6107. // ResolveReferences resolves references found inside NamedSchema objects.
  6108. func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) {
  6109. errors := make([]error, 0)
  6110. if m.Value != nil {
  6111. _, err := m.Value.ResolveReferences(root)
  6112. if err != nil {
  6113. errors = append(errors, err)
  6114. }
  6115. }
  6116. return nil, compiler.NewErrorGroupOrNil(errors)
  6117. }
  6118. // ResolveReferences resolves references found inside NamedSecurityDefinitionsItem objects.
  6119. func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) {
  6120. errors := make([]error, 0)
  6121. if m.Value != nil {
  6122. _, err := m.Value.ResolveReferences(root)
  6123. if err != nil {
  6124. errors = append(errors, err)
  6125. }
  6126. }
  6127. return nil, compiler.NewErrorGroupOrNil(errors)
  6128. }
  6129. // ResolveReferences resolves references found inside NamedString objects.
  6130. func (m *NamedString) ResolveReferences(root string) (interface{}, error) {
  6131. errors := make([]error, 0)
  6132. return nil, compiler.NewErrorGroupOrNil(errors)
  6133. }
  6134. // ResolveReferences resolves references found inside NamedStringArray objects.
  6135. func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) {
  6136. errors := make([]error, 0)
  6137. if m.Value != nil {
  6138. _, err := m.Value.ResolveReferences(root)
  6139. if err != nil {
  6140. errors = append(errors, err)
  6141. }
  6142. }
  6143. return nil, compiler.NewErrorGroupOrNil(errors)
  6144. }
  6145. // ResolveReferences resolves references found inside NonBodyParameter objects.
  6146. func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) {
  6147. errors := make([]error, 0)
  6148. {
  6149. p, ok := m.Oneof.(*NonBodyParameter_HeaderParameterSubSchema)
  6150. if ok {
  6151. _, err := p.HeaderParameterSubSchema.ResolveReferences(root)
  6152. if err != nil {
  6153. return nil, err
  6154. }
  6155. }
  6156. }
  6157. {
  6158. p, ok := m.Oneof.(*NonBodyParameter_FormDataParameterSubSchema)
  6159. if ok {
  6160. _, err := p.FormDataParameterSubSchema.ResolveReferences(root)
  6161. if err != nil {
  6162. return nil, err
  6163. }
  6164. }
  6165. }
  6166. {
  6167. p, ok := m.Oneof.(*NonBodyParameter_QueryParameterSubSchema)
  6168. if ok {
  6169. _, err := p.QueryParameterSubSchema.ResolveReferences(root)
  6170. if err != nil {
  6171. return nil, err
  6172. }
  6173. }
  6174. }
  6175. {
  6176. p, ok := m.Oneof.(*NonBodyParameter_PathParameterSubSchema)
  6177. if ok {
  6178. _, err := p.PathParameterSubSchema.ResolveReferences(root)
  6179. if err != nil {
  6180. return nil, err
  6181. }
  6182. }
  6183. }
  6184. return nil, compiler.NewErrorGroupOrNil(errors)
  6185. }
  6186. // ResolveReferences resolves references found inside Oauth2AccessCodeSecurity objects.
  6187. func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, error) {
  6188. errors := make([]error, 0)
  6189. if m.Scopes != nil {
  6190. _, err := m.Scopes.ResolveReferences(root)
  6191. if err != nil {
  6192. errors = append(errors, err)
  6193. }
  6194. }
  6195. for _, item := range m.VendorExtension {
  6196. if item != nil {
  6197. _, err := item.ResolveReferences(root)
  6198. if err != nil {
  6199. errors = append(errors, err)
  6200. }
  6201. }
  6202. }
  6203. return nil, compiler.NewErrorGroupOrNil(errors)
  6204. }
  6205. // ResolveReferences resolves references found inside Oauth2ApplicationSecurity objects.
  6206. func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, error) {
  6207. errors := make([]error, 0)
  6208. if m.Scopes != nil {
  6209. _, err := m.Scopes.ResolveReferences(root)
  6210. if err != nil {
  6211. errors = append(errors, err)
  6212. }
  6213. }
  6214. for _, item := range m.VendorExtension {
  6215. if item != nil {
  6216. _, err := item.ResolveReferences(root)
  6217. if err != nil {
  6218. errors = append(errors, err)
  6219. }
  6220. }
  6221. }
  6222. return nil, compiler.NewErrorGroupOrNil(errors)
  6223. }
  6224. // ResolveReferences resolves references found inside Oauth2ImplicitSecurity objects.
  6225. func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, error) {
  6226. errors := make([]error, 0)
  6227. if m.Scopes != nil {
  6228. _, err := m.Scopes.ResolveReferences(root)
  6229. if err != nil {
  6230. errors = append(errors, err)
  6231. }
  6232. }
  6233. for _, item := range m.VendorExtension {
  6234. if item != nil {
  6235. _, err := item.ResolveReferences(root)
  6236. if err != nil {
  6237. errors = append(errors, err)
  6238. }
  6239. }
  6240. }
  6241. return nil, compiler.NewErrorGroupOrNil(errors)
  6242. }
  6243. // ResolveReferences resolves references found inside Oauth2PasswordSecurity objects.
  6244. func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, error) {
  6245. errors := make([]error, 0)
  6246. if m.Scopes != nil {
  6247. _, err := m.Scopes.ResolveReferences(root)
  6248. if err != nil {
  6249. errors = append(errors, err)
  6250. }
  6251. }
  6252. for _, item := range m.VendorExtension {
  6253. if item != nil {
  6254. _, err := item.ResolveReferences(root)
  6255. if err != nil {
  6256. errors = append(errors, err)
  6257. }
  6258. }
  6259. }
  6260. return nil, compiler.NewErrorGroupOrNil(errors)
  6261. }
  6262. // ResolveReferences resolves references found inside Oauth2Scopes objects.
  6263. func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) {
  6264. errors := make([]error, 0)
  6265. for _, item := range m.AdditionalProperties {
  6266. if item != nil {
  6267. _, err := item.ResolveReferences(root)
  6268. if err != nil {
  6269. errors = append(errors, err)
  6270. }
  6271. }
  6272. }
  6273. return nil, compiler.NewErrorGroupOrNil(errors)
  6274. }
  6275. // ResolveReferences resolves references found inside Operation objects.
  6276. func (m *Operation) ResolveReferences(root string) (interface{}, error) {
  6277. errors := make([]error, 0)
  6278. if m.ExternalDocs != nil {
  6279. _, err := m.ExternalDocs.ResolveReferences(root)
  6280. if err != nil {
  6281. errors = append(errors, err)
  6282. }
  6283. }
  6284. for _, item := range m.Parameters {
  6285. if item != nil {
  6286. _, err := item.ResolveReferences(root)
  6287. if err != nil {
  6288. errors = append(errors, err)
  6289. }
  6290. }
  6291. }
  6292. if m.Responses != nil {
  6293. _, err := m.Responses.ResolveReferences(root)
  6294. if err != nil {
  6295. errors = append(errors, err)
  6296. }
  6297. }
  6298. for _, item := range m.Security {
  6299. if item != nil {
  6300. _, err := item.ResolveReferences(root)
  6301. if err != nil {
  6302. errors = append(errors, err)
  6303. }
  6304. }
  6305. }
  6306. for _, item := range m.VendorExtension {
  6307. if item != nil {
  6308. _, err := item.ResolveReferences(root)
  6309. if err != nil {
  6310. errors = append(errors, err)
  6311. }
  6312. }
  6313. }
  6314. return nil, compiler.NewErrorGroupOrNil(errors)
  6315. }
  6316. // ResolveReferences resolves references found inside Parameter objects.
  6317. func (m *Parameter) ResolveReferences(root string) (interface{}, error) {
  6318. errors := make([]error, 0)
  6319. {
  6320. p, ok := m.Oneof.(*Parameter_BodyParameter)
  6321. if ok {
  6322. _, err := p.BodyParameter.ResolveReferences(root)
  6323. if err != nil {
  6324. return nil, err
  6325. }
  6326. }
  6327. }
  6328. {
  6329. p, ok := m.Oneof.(*Parameter_NonBodyParameter)
  6330. if ok {
  6331. _, err := p.NonBodyParameter.ResolveReferences(root)
  6332. if err != nil {
  6333. return nil, err
  6334. }
  6335. }
  6336. }
  6337. return nil, compiler.NewErrorGroupOrNil(errors)
  6338. }
  6339. // ResolveReferences resolves references found inside ParameterDefinitions objects.
  6340. func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, error) {
  6341. errors := make([]error, 0)
  6342. for _, item := range m.AdditionalProperties {
  6343. if item != nil {
  6344. _, err := item.ResolveReferences(root)
  6345. if err != nil {
  6346. errors = append(errors, err)
  6347. }
  6348. }
  6349. }
  6350. return nil, compiler.NewErrorGroupOrNil(errors)
  6351. }
  6352. // ResolveReferences resolves references found inside ParametersItem objects.
  6353. func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) {
  6354. errors := make([]error, 0)
  6355. {
  6356. p, ok := m.Oneof.(*ParametersItem_Parameter)
  6357. if ok {
  6358. _, err := p.Parameter.ResolveReferences(root)
  6359. if err != nil {
  6360. return nil, err
  6361. }
  6362. }
  6363. }
  6364. {
  6365. p, ok := m.Oneof.(*ParametersItem_JsonReference)
  6366. if ok {
  6367. info, err := p.JsonReference.ResolveReferences(root)
  6368. if err != nil {
  6369. return nil, err
  6370. } else if info != nil {
  6371. n, err := NewParametersItem(info, nil)
  6372. if err != nil {
  6373. return nil, err
  6374. } else if n != nil {
  6375. *m = *n
  6376. return nil, nil
  6377. }
  6378. }
  6379. }
  6380. }
  6381. return nil, compiler.NewErrorGroupOrNil(errors)
  6382. }
  6383. // ResolveReferences resolves references found inside PathItem objects.
  6384. func (m *PathItem) ResolveReferences(root string) (interface{}, error) {
  6385. errors := make([]error, 0)
  6386. if m.XRef != "" {
  6387. info, err := compiler.ReadInfoForRef(root, m.XRef)
  6388. if err != nil {
  6389. return nil, err
  6390. }
  6391. if info != nil {
  6392. replacement, err := NewPathItem(info, nil)
  6393. if err == nil {
  6394. *m = *replacement
  6395. return m.ResolveReferences(root)
  6396. }
  6397. }
  6398. return info, nil
  6399. }
  6400. if m.Get != nil {
  6401. _, err := m.Get.ResolveReferences(root)
  6402. if err != nil {
  6403. errors = append(errors, err)
  6404. }
  6405. }
  6406. if m.Put != nil {
  6407. _, err := m.Put.ResolveReferences(root)
  6408. if err != nil {
  6409. errors = append(errors, err)
  6410. }
  6411. }
  6412. if m.Post != nil {
  6413. _, err := m.Post.ResolveReferences(root)
  6414. if err != nil {
  6415. errors = append(errors, err)
  6416. }
  6417. }
  6418. if m.Delete != nil {
  6419. _, err := m.Delete.ResolveReferences(root)
  6420. if err != nil {
  6421. errors = append(errors, err)
  6422. }
  6423. }
  6424. if m.Options != nil {
  6425. _, err := m.Options.ResolveReferences(root)
  6426. if err != nil {
  6427. errors = append(errors, err)
  6428. }
  6429. }
  6430. if m.Head != nil {
  6431. _, err := m.Head.ResolveReferences(root)
  6432. if err != nil {
  6433. errors = append(errors, err)
  6434. }
  6435. }
  6436. if m.Patch != nil {
  6437. _, err := m.Patch.ResolveReferences(root)
  6438. if err != nil {
  6439. errors = append(errors, err)
  6440. }
  6441. }
  6442. for _, item := range m.Parameters {
  6443. if item != nil {
  6444. _, err := item.ResolveReferences(root)
  6445. if err != nil {
  6446. errors = append(errors, err)
  6447. }
  6448. }
  6449. }
  6450. for _, item := range m.VendorExtension {
  6451. if item != nil {
  6452. _, err := item.ResolveReferences(root)
  6453. if err != nil {
  6454. errors = append(errors, err)
  6455. }
  6456. }
  6457. }
  6458. return nil, compiler.NewErrorGroupOrNil(errors)
  6459. }
  6460. // ResolveReferences resolves references found inside PathParameterSubSchema objects.
  6461. func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, error) {
  6462. errors := make([]error, 0)
  6463. if m.Items != nil {
  6464. _, err := m.Items.ResolveReferences(root)
  6465. if err != nil {
  6466. errors = append(errors, err)
  6467. }
  6468. }
  6469. if m.Default != nil {
  6470. _, err := m.Default.ResolveReferences(root)
  6471. if err != nil {
  6472. errors = append(errors, err)
  6473. }
  6474. }
  6475. for _, item := range m.Enum {
  6476. if item != nil {
  6477. _, err := item.ResolveReferences(root)
  6478. if err != nil {
  6479. errors = append(errors, err)
  6480. }
  6481. }
  6482. }
  6483. for _, item := range m.VendorExtension {
  6484. if item != nil {
  6485. _, err := item.ResolveReferences(root)
  6486. if err != nil {
  6487. errors = append(errors, err)
  6488. }
  6489. }
  6490. }
  6491. return nil, compiler.NewErrorGroupOrNil(errors)
  6492. }
  6493. // ResolveReferences resolves references found inside Paths objects.
  6494. func (m *Paths) ResolveReferences(root string) (interface{}, error) {
  6495. errors := make([]error, 0)
  6496. for _, item := range m.VendorExtension {
  6497. if item != nil {
  6498. _, err := item.ResolveReferences(root)
  6499. if err != nil {
  6500. errors = append(errors, err)
  6501. }
  6502. }
  6503. }
  6504. for _, item := range m.Path {
  6505. if item != nil {
  6506. _, err := item.ResolveReferences(root)
  6507. if err != nil {
  6508. errors = append(errors, err)
  6509. }
  6510. }
  6511. }
  6512. return nil, compiler.NewErrorGroupOrNil(errors)
  6513. }
  6514. // ResolveReferences resolves references found inside PrimitivesItems objects.
  6515. func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) {
  6516. errors := make([]error, 0)
  6517. if m.Items != nil {
  6518. _, err := m.Items.ResolveReferences(root)
  6519. if err != nil {
  6520. errors = append(errors, err)
  6521. }
  6522. }
  6523. if m.Default != nil {
  6524. _, err := m.Default.ResolveReferences(root)
  6525. if err != nil {
  6526. errors = append(errors, err)
  6527. }
  6528. }
  6529. for _, item := range m.Enum {
  6530. if item != nil {
  6531. _, err := item.ResolveReferences(root)
  6532. if err != nil {
  6533. errors = append(errors, err)
  6534. }
  6535. }
  6536. }
  6537. for _, item := range m.VendorExtension {
  6538. if item != nil {
  6539. _, err := item.ResolveReferences(root)
  6540. if err != nil {
  6541. errors = append(errors, err)
  6542. }
  6543. }
  6544. }
  6545. return nil, compiler.NewErrorGroupOrNil(errors)
  6546. }
  6547. // ResolveReferences resolves references found inside Properties objects.
  6548. func (m *Properties) ResolveReferences(root string) (interface{}, error) {
  6549. errors := make([]error, 0)
  6550. for _, item := range m.AdditionalProperties {
  6551. if item != nil {
  6552. _, err := item.ResolveReferences(root)
  6553. if err != nil {
  6554. errors = append(errors, err)
  6555. }
  6556. }
  6557. }
  6558. return nil, compiler.NewErrorGroupOrNil(errors)
  6559. }
  6560. // ResolveReferences resolves references found inside QueryParameterSubSchema objects.
  6561. func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, error) {
  6562. errors := make([]error, 0)
  6563. if m.Items != nil {
  6564. _, err := m.Items.ResolveReferences(root)
  6565. if err != nil {
  6566. errors = append(errors, err)
  6567. }
  6568. }
  6569. if m.Default != nil {
  6570. _, err := m.Default.ResolveReferences(root)
  6571. if err != nil {
  6572. errors = append(errors, err)
  6573. }
  6574. }
  6575. for _, item := range m.Enum {
  6576. if item != nil {
  6577. _, err := item.ResolveReferences(root)
  6578. if err != nil {
  6579. errors = append(errors, err)
  6580. }
  6581. }
  6582. }
  6583. for _, item := range m.VendorExtension {
  6584. if item != nil {
  6585. _, err := item.ResolveReferences(root)
  6586. if err != nil {
  6587. errors = append(errors, err)
  6588. }
  6589. }
  6590. }
  6591. return nil, compiler.NewErrorGroupOrNil(errors)
  6592. }
  6593. // ResolveReferences resolves references found inside Response objects.
  6594. func (m *Response) ResolveReferences(root string) (interface{}, error) {
  6595. errors := make([]error, 0)
  6596. if m.Schema != nil {
  6597. _, err := m.Schema.ResolveReferences(root)
  6598. if err != nil {
  6599. errors = append(errors, err)
  6600. }
  6601. }
  6602. if m.Headers != nil {
  6603. _, err := m.Headers.ResolveReferences(root)
  6604. if err != nil {
  6605. errors = append(errors, err)
  6606. }
  6607. }
  6608. if m.Examples != nil {
  6609. _, err := m.Examples.ResolveReferences(root)
  6610. if err != nil {
  6611. errors = append(errors, err)
  6612. }
  6613. }
  6614. for _, item := range m.VendorExtension {
  6615. if item != nil {
  6616. _, err := item.ResolveReferences(root)
  6617. if err != nil {
  6618. errors = append(errors, err)
  6619. }
  6620. }
  6621. }
  6622. return nil, compiler.NewErrorGroupOrNil(errors)
  6623. }
  6624. // ResolveReferences resolves references found inside ResponseDefinitions objects.
  6625. func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error) {
  6626. errors := make([]error, 0)
  6627. for _, item := range m.AdditionalProperties {
  6628. if item != nil {
  6629. _, err := item.ResolveReferences(root)
  6630. if err != nil {
  6631. errors = append(errors, err)
  6632. }
  6633. }
  6634. }
  6635. return nil, compiler.NewErrorGroupOrNil(errors)
  6636. }
  6637. // ResolveReferences resolves references found inside ResponseValue objects.
  6638. func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) {
  6639. errors := make([]error, 0)
  6640. {
  6641. p, ok := m.Oneof.(*ResponseValue_Response)
  6642. if ok {
  6643. _, err := p.Response.ResolveReferences(root)
  6644. if err != nil {
  6645. return nil, err
  6646. }
  6647. }
  6648. }
  6649. {
  6650. p, ok := m.Oneof.(*ResponseValue_JsonReference)
  6651. if ok {
  6652. info, err := p.JsonReference.ResolveReferences(root)
  6653. if err != nil {
  6654. return nil, err
  6655. } else if info != nil {
  6656. n, err := NewResponseValue(info, nil)
  6657. if err != nil {
  6658. return nil, err
  6659. } else if n != nil {
  6660. *m = *n
  6661. return nil, nil
  6662. }
  6663. }
  6664. }
  6665. }
  6666. return nil, compiler.NewErrorGroupOrNil(errors)
  6667. }
  6668. // ResolveReferences resolves references found inside Responses objects.
  6669. func (m *Responses) ResolveReferences(root string) (interface{}, error) {
  6670. errors := make([]error, 0)
  6671. for _, item := range m.ResponseCode {
  6672. if item != nil {
  6673. _, err := item.ResolveReferences(root)
  6674. if err != nil {
  6675. errors = append(errors, err)
  6676. }
  6677. }
  6678. }
  6679. for _, item := range m.VendorExtension {
  6680. if item != nil {
  6681. _, err := item.ResolveReferences(root)
  6682. if err != nil {
  6683. errors = append(errors, err)
  6684. }
  6685. }
  6686. }
  6687. return nil, compiler.NewErrorGroupOrNil(errors)
  6688. }
  6689. // ResolveReferences resolves references found inside Schema objects.
  6690. func (m *Schema) ResolveReferences(root string) (interface{}, error) {
  6691. errors := make([]error, 0)
  6692. if m.XRef != "" {
  6693. info, err := compiler.ReadInfoForRef(root, m.XRef)
  6694. if err != nil {
  6695. return nil, err
  6696. }
  6697. if info != nil {
  6698. replacement, err := NewSchema(info, nil)
  6699. if err == nil {
  6700. *m = *replacement
  6701. return m.ResolveReferences(root)
  6702. }
  6703. }
  6704. return info, nil
  6705. }
  6706. if m.Default != nil {
  6707. _, err := m.Default.ResolveReferences(root)
  6708. if err != nil {
  6709. errors = append(errors, err)
  6710. }
  6711. }
  6712. for _, item := range m.Enum {
  6713. if item != nil {
  6714. _, err := item.ResolveReferences(root)
  6715. if err != nil {
  6716. errors = append(errors, err)
  6717. }
  6718. }
  6719. }
  6720. if m.AdditionalProperties != nil {
  6721. _, err := m.AdditionalProperties.ResolveReferences(root)
  6722. if err != nil {
  6723. errors = append(errors, err)
  6724. }
  6725. }
  6726. if m.Type != nil {
  6727. _, err := m.Type.ResolveReferences(root)
  6728. if err != nil {
  6729. errors = append(errors, err)
  6730. }
  6731. }
  6732. if m.Items != nil {
  6733. _, err := m.Items.ResolveReferences(root)
  6734. if err != nil {
  6735. errors = append(errors, err)
  6736. }
  6737. }
  6738. for _, item := range m.AllOf {
  6739. if item != nil {
  6740. _, err := item.ResolveReferences(root)
  6741. if err != nil {
  6742. errors = append(errors, err)
  6743. }
  6744. }
  6745. }
  6746. if m.Properties != nil {
  6747. _, err := m.Properties.ResolveReferences(root)
  6748. if err != nil {
  6749. errors = append(errors, err)
  6750. }
  6751. }
  6752. if m.Xml != nil {
  6753. _, err := m.Xml.ResolveReferences(root)
  6754. if err != nil {
  6755. errors = append(errors, err)
  6756. }
  6757. }
  6758. if m.ExternalDocs != nil {
  6759. _, err := m.ExternalDocs.ResolveReferences(root)
  6760. if err != nil {
  6761. errors = append(errors, err)
  6762. }
  6763. }
  6764. if m.Example != nil {
  6765. _, err := m.Example.ResolveReferences(root)
  6766. if err != nil {
  6767. errors = append(errors, err)
  6768. }
  6769. }
  6770. for _, item := range m.VendorExtension {
  6771. if item != nil {
  6772. _, err := item.ResolveReferences(root)
  6773. if err != nil {
  6774. errors = append(errors, err)
  6775. }
  6776. }
  6777. }
  6778. return nil, compiler.NewErrorGroupOrNil(errors)
  6779. }
  6780. // ResolveReferences resolves references found inside SchemaItem objects.
  6781. func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) {
  6782. errors := make([]error, 0)
  6783. {
  6784. p, ok := m.Oneof.(*SchemaItem_Schema)
  6785. if ok {
  6786. _, err := p.Schema.ResolveReferences(root)
  6787. if err != nil {
  6788. return nil, err
  6789. }
  6790. }
  6791. }
  6792. {
  6793. p, ok := m.Oneof.(*SchemaItem_FileSchema)
  6794. if ok {
  6795. _, err := p.FileSchema.ResolveReferences(root)
  6796. if err != nil {
  6797. return nil, err
  6798. }
  6799. }
  6800. }
  6801. return nil, compiler.NewErrorGroupOrNil(errors)
  6802. }
  6803. // ResolveReferences resolves references found inside SecurityDefinitions objects.
  6804. func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error) {
  6805. errors := make([]error, 0)
  6806. for _, item := range m.AdditionalProperties {
  6807. if item != nil {
  6808. _, err := item.ResolveReferences(root)
  6809. if err != nil {
  6810. errors = append(errors, err)
  6811. }
  6812. }
  6813. }
  6814. return nil, compiler.NewErrorGroupOrNil(errors)
  6815. }
  6816. // ResolveReferences resolves references found inside SecurityDefinitionsItem objects.
  6817. func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) {
  6818. errors := make([]error, 0)
  6819. {
  6820. p, ok := m.Oneof.(*SecurityDefinitionsItem_BasicAuthenticationSecurity)
  6821. if ok {
  6822. _, err := p.BasicAuthenticationSecurity.ResolveReferences(root)
  6823. if err != nil {
  6824. return nil, err
  6825. }
  6826. }
  6827. }
  6828. {
  6829. p, ok := m.Oneof.(*SecurityDefinitionsItem_ApiKeySecurity)
  6830. if ok {
  6831. _, err := p.ApiKeySecurity.ResolveReferences(root)
  6832. if err != nil {
  6833. return nil, err
  6834. }
  6835. }
  6836. }
  6837. {
  6838. p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2ImplicitSecurity)
  6839. if ok {
  6840. _, err := p.Oauth2ImplicitSecurity.ResolveReferences(root)
  6841. if err != nil {
  6842. return nil, err
  6843. }
  6844. }
  6845. }
  6846. {
  6847. p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2PasswordSecurity)
  6848. if ok {
  6849. _, err := p.Oauth2PasswordSecurity.ResolveReferences(root)
  6850. if err != nil {
  6851. return nil, err
  6852. }
  6853. }
  6854. }
  6855. {
  6856. p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2ApplicationSecurity)
  6857. if ok {
  6858. _, err := p.Oauth2ApplicationSecurity.ResolveReferences(root)
  6859. if err != nil {
  6860. return nil, err
  6861. }
  6862. }
  6863. }
  6864. {
  6865. p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2AccessCodeSecurity)
  6866. if ok {
  6867. _, err := p.Oauth2AccessCodeSecurity.ResolveReferences(root)
  6868. if err != nil {
  6869. return nil, err
  6870. }
  6871. }
  6872. }
  6873. return nil, compiler.NewErrorGroupOrNil(errors)
  6874. }
  6875. // ResolveReferences resolves references found inside SecurityRequirement objects.
  6876. func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) {
  6877. errors := make([]error, 0)
  6878. for _, item := range m.AdditionalProperties {
  6879. if item != nil {
  6880. _, err := item.ResolveReferences(root)
  6881. if err != nil {
  6882. errors = append(errors, err)
  6883. }
  6884. }
  6885. }
  6886. return nil, compiler.NewErrorGroupOrNil(errors)
  6887. }
  6888. // ResolveReferences resolves references found inside StringArray objects.
  6889. func (m *StringArray) ResolveReferences(root string) (interface{}, error) {
  6890. errors := make([]error, 0)
  6891. return nil, compiler.NewErrorGroupOrNil(errors)
  6892. }
  6893. // ResolveReferences resolves references found inside Tag objects.
  6894. func (m *Tag) ResolveReferences(root string) (interface{}, error) {
  6895. errors := make([]error, 0)
  6896. if m.ExternalDocs != nil {
  6897. _, err := m.ExternalDocs.ResolveReferences(root)
  6898. if err != nil {
  6899. errors = append(errors, err)
  6900. }
  6901. }
  6902. for _, item := range m.VendorExtension {
  6903. if item != nil {
  6904. _, err := item.ResolveReferences(root)
  6905. if err != nil {
  6906. errors = append(errors, err)
  6907. }
  6908. }
  6909. }
  6910. return nil, compiler.NewErrorGroupOrNil(errors)
  6911. }
  6912. // ResolveReferences resolves references found inside TypeItem objects.
  6913. func (m *TypeItem) ResolveReferences(root string) (interface{}, error) {
  6914. errors := make([]error, 0)
  6915. return nil, compiler.NewErrorGroupOrNil(errors)
  6916. }
  6917. // ResolveReferences resolves references found inside VendorExtension objects.
  6918. func (m *VendorExtension) ResolveReferences(root string) (interface{}, error) {
  6919. errors := make([]error, 0)
  6920. for _, item := range m.AdditionalProperties {
  6921. if item != nil {
  6922. _, err := item.ResolveReferences(root)
  6923. if err != nil {
  6924. errors = append(errors, err)
  6925. }
  6926. }
  6927. }
  6928. return nil, compiler.NewErrorGroupOrNil(errors)
  6929. }
  6930. // ResolveReferences resolves references found inside Xml objects.
  6931. func (m *Xml) ResolveReferences(root string) (interface{}, error) {
  6932. errors := make([]error, 0)
  6933. for _, item := range m.VendorExtension {
  6934. if item != nil {
  6935. _, err := item.ResolveReferences(root)
  6936. if err != nil {
  6937. errors = append(errors, err)
  6938. }
  6939. }
  6940. }
  6941. return nil, compiler.NewErrorGroupOrNil(errors)
  6942. }
  6943. // ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export.
  6944. func (m *AdditionalPropertiesItem) ToRawInfo() interface{} {
  6945. // ONE OF WRAPPER
  6946. // AdditionalPropertiesItem
  6947. // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  6948. v0 := m.GetSchema()
  6949. if v0 != nil {
  6950. return v0.ToRawInfo()
  6951. }
  6952. // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  6953. if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok {
  6954. return v1.Boolean
  6955. }
  6956. return nil
  6957. }
  6958. // ToRawInfo returns a description of Any suitable for JSON or YAML export.
  6959. func (m *Any) ToRawInfo() interface{} {
  6960. var err error
  6961. var info1 []yaml.MapSlice
  6962. err = yaml.Unmarshal([]byte(m.Yaml), &info1)
  6963. if err == nil {
  6964. return info1
  6965. }
  6966. var info2 yaml.MapSlice
  6967. err = yaml.Unmarshal([]byte(m.Yaml), &info2)
  6968. if err == nil {
  6969. return info2
  6970. }
  6971. var info3 interface{}
  6972. err = yaml.Unmarshal([]byte(m.Yaml), &info3)
  6973. if err == nil {
  6974. return info3
  6975. }
  6976. return nil
  6977. }
  6978. // ToRawInfo returns a description of ApiKeySecurity suitable for JSON or YAML export.
  6979. func (m *ApiKeySecurity) ToRawInfo() interface{} {
  6980. info := yaml.MapSlice{}
  6981. if m.Type != "" {
  6982. info = append(info, yaml.MapItem{"type", m.Type})
  6983. }
  6984. if m.Name != "" {
  6985. info = append(info, yaml.MapItem{"name", m.Name})
  6986. }
  6987. if m.In != "" {
  6988. info = append(info, yaml.MapItem{"in", m.In})
  6989. }
  6990. if m.Description != "" {
  6991. info = append(info, yaml.MapItem{"description", m.Description})
  6992. }
  6993. if m.VendorExtension != nil {
  6994. for _, item := range m.VendorExtension {
  6995. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  6996. }
  6997. }
  6998. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  6999. return info
  7000. }
  7001. // ToRawInfo returns a description of BasicAuthenticationSecurity suitable for JSON or YAML export.
  7002. func (m *BasicAuthenticationSecurity) ToRawInfo() interface{} {
  7003. info := yaml.MapSlice{}
  7004. if m.Type != "" {
  7005. info = append(info, yaml.MapItem{"type", m.Type})
  7006. }
  7007. if m.Description != "" {
  7008. info = append(info, yaml.MapItem{"description", m.Description})
  7009. }
  7010. if m.VendorExtension != nil {
  7011. for _, item := range m.VendorExtension {
  7012. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7013. }
  7014. }
  7015. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7016. return info
  7017. }
  7018. // ToRawInfo returns a description of BodyParameter suitable for JSON or YAML export.
  7019. func (m *BodyParameter) ToRawInfo() interface{} {
  7020. info := yaml.MapSlice{}
  7021. if m.Description != "" {
  7022. info = append(info, yaml.MapItem{"description", m.Description})
  7023. }
  7024. if m.Name != "" {
  7025. info = append(info, yaml.MapItem{"name", m.Name})
  7026. }
  7027. if m.In != "" {
  7028. info = append(info, yaml.MapItem{"in", m.In})
  7029. }
  7030. if m.Required != false {
  7031. info = append(info, yaml.MapItem{"required", m.Required})
  7032. }
  7033. if m.Schema != nil {
  7034. info = append(info, yaml.MapItem{"schema", m.Schema.ToRawInfo()})
  7035. }
  7036. // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7037. if m.VendorExtension != nil {
  7038. for _, item := range m.VendorExtension {
  7039. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7040. }
  7041. }
  7042. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7043. return info
  7044. }
  7045. // ToRawInfo returns a description of Contact suitable for JSON or YAML export.
  7046. func (m *Contact) ToRawInfo() interface{} {
  7047. info := yaml.MapSlice{}
  7048. if m.Name != "" {
  7049. info = append(info, yaml.MapItem{"name", m.Name})
  7050. }
  7051. if m.Url != "" {
  7052. info = append(info, yaml.MapItem{"url", m.Url})
  7053. }
  7054. if m.Email != "" {
  7055. info = append(info, yaml.MapItem{"email", m.Email})
  7056. }
  7057. if m.VendorExtension != nil {
  7058. for _, item := range m.VendorExtension {
  7059. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7060. }
  7061. }
  7062. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7063. return info
  7064. }
  7065. // ToRawInfo returns a description of Default suitable for JSON or YAML export.
  7066. func (m *Default) ToRawInfo() interface{} {
  7067. info := yaml.MapSlice{}
  7068. if m.AdditionalProperties != nil {
  7069. for _, item := range m.AdditionalProperties {
  7070. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7071. }
  7072. }
  7073. // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:false Description:}
  7074. return info
  7075. }
  7076. // ToRawInfo returns a description of Definitions suitable for JSON or YAML export.
  7077. func (m *Definitions) ToRawInfo() interface{} {
  7078. info := yaml.MapSlice{}
  7079. if m.AdditionalProperties != nil {
  7080. for _, item := range m.AdditionalProperties {
  7081. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7082. }
  7083. }
  7084. // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:}
  7085. return info
  7086. }
  7087. // ToRawInfo returns a description of Document suitable for JSON or YAML export.
  7088. func (m *Document) ToRawInfo() interface{} {
  7089. info := yaml.MapSlice{}
  7090. if m.Swagger != "" {
  7091. info = append(info, yaml.MapItem{"swagger", m.Swagger})
  7092. }
  7093. if m.Info != nil {
  7094. info = append(info, yaml.MapItem{"info", m.Info.ToRawInfo()})
  7095. }
  7096. // &{Name:info Type:Info StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7097. if m.Host != "" {
  7098. info = append(info, yaml.MapItem{"host", m.Host})
  7099. }
  7100. if m.BasePath != "" {
  7101. info = append(info, yaml.MapItem{"basePath", m.BasePath})
  7102. }
  7103. if len(m.Schemes) != 0 {
  7104. info = append(info, yaml.MapItem{"schemes", m.Schemes})
  7105. }
  7106. if len(m.Consumes) != 0 {
  7107. info = append(info, yaml.MapItem{"consumes", m.Consumes})
  7108. }
  7109. if len(m.Produces) != 0 {
  7110. info = append(info, yaml.MapItem{"produces", m.Produces})
  7111. }
  7112. if m.Paths != nil {
  7113. info = append(info, yaml.MapItem{"paths", m.Paths.ToRawInfo()})
  7114. }
  7115. // &{Name:paths Type:Paths StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7116. if m.Definitions != nil {
  7117. info = append(info, yaml.MapItem{"definitions", m.Definitions.ToRawInfo()})
  7118. }
  7119. // &{Name:definitions Type:Definitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7120. if m.Parameters != nil {
  7121. info = append(info, yaml.MapItem{"parameters", m.Parameters.ToRawInfo()})
  7122. }
  7123. // &{Name:parameters Type:ParameterDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7124. if m.Responses != nil {
  7125. info = append(info, yaml.MapItem{"responses", m.Responses.ToRawInfo()})
  7126. }
  7127. // &{Name:responses Type:ResponseDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7128. if len(m.Security) != 0 {
  7129. items := make([]interface{}, 0)
  7130. for _, item := range m.Security {
  7131. items = append(items, item.ToRawInfo())
  7132. }
  7133. info = append(info, yaml.MapItem{"security", items})
  7134. }
  7135. // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7136. if m.SecurityDefinitions != nil {
  7137. info = append(info, yaml.MapItem{"securityDefinitions", m.SecurityDefinitions.ToRawInfo()})
  7138. }
  7139. // &{Name:securityDefinitions Type:SecurityDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7140. if len(m.Tags) != 0 {
  7141. items := make([]interface{}, 0)
  7142. for _, item := range m.Tags {
  7143. items = append(items, item.ToRawInfo())
  7144. }
  7145. info = append(info, yaml.MapItem{"tags", items})
  7146. }
  7147. // &{Name:tags Type:Tag StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7148. if m.ExternalDocs != nil {
  7149. info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()})
  7150. }
  7151. // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7152. if m.VendorExtension != nil {
  7153. for _, item := range m.VendorExtension {
  7154. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7155. }
  7156. }
  7157. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7158. return info
  7159. }
  7160. // ToRawInfo returns a description of Examples suitable for JSON or YAML export.
  7161. func (m *Examples) ToRawInfo() interface{} {
  7162. info := yaml.MapSlice{}
  7163. if m.AdditionalProperties != nil {
  7164. for _, item := range m.AdditionalProperties {
  7165. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7166. }
  7167. }
  7168. // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:}
  7169. return info
  7170. }
  7171. // ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export.
  7172. func (m *ExternalDocs) ToRawInfo() interface{} {
  7173. info := yaml.MapSlice{}
  7174. if m.Description != "" {
  7175. info = append(info, yaml.MapItem{"description", m.Description})
  7176. }
  7177. if m.Url != "" {
  7178. info = append(info, yaml.MapItem{"url", m.Url})
  7179. }
  7180. if m.VendorExtension != nil {
  7181. for _, item := range m.VendorExtension {
  7182. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7183. }
  7184. }
  7185. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7186. return info
  7187. }
  7188. // ToRawInfo returns a description of FileSchema suitable for JSON or YAML export.
  7189. func (m *FileSchema) ToRawInfo() interface{} {
  7190. info := yaml.MapSlice{}
  7191. if m.Format != "" {
  7192. info = append(info, yaml.MapItem{"format", m.Format})
  7193. }
  7194. if m.Title != "" {
  7195. info = append(info, yaml.MapItem{"title", m.Title})
  7196. }
  7197. if m.Description != "" {
  7198. info = append(info, yaml.MapItem{"description", m.Description})
  7199. }
  7200. if m.Default != nil {
  7201. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  7202. }
  7203. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7204. if len(m.Required) != 0 {
  7205. info = append(info, yaml.MapItem{"required", m.Required})
  7206. }
  7207. if m.Type != "" {
  7208. info = append(info, yaml.MapItem{"type", m.Type})
  7209. }
  7210. if m.ReadOnly != false {
  7211. info = append(info, yaml.MapItem{"readOnly", m.ReadOnly})
  7212. }
  7213. if m.ExternalDocs != nil {
  7214. info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()})
  7215. }
  7216. // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7217. if m.Example != nil {
  7218. info = append(info, yaml.MapItem{"example", m.Example.ToRawInfo()})
  7219. }
  7220. // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7221. if m.VendorExtension != nil {
  7222. for _, item := range m.VendorExtension {
  7223. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7224. }
  7225. }
  7226. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7227. return info
  7228. }
  7229. // ToRawInfo returns a description of FormDataParameterSubSchema suitable for JSON or YAML export.
  7230. func (m *FormDataParameterSubSchema) ToRawInfo() interface{} {
  7231. info := yaml.MapSlice{}
  7232. if m.Required != false {
  7233. info = append(info, yaml.MapItem{"required", m.Required})
  7234. }
  7235. if m.In != "" {
  7236. info = append(info, yaml.MapItem{"in", m.In})
  7237. }
  7238. if m.Description != "" {
  7239. info = append(info, yaml.MapItem{"description", m.Description})
  7240. }
  7241. if m.Name != "" {
  7242. info = append(info, yaml.MapItem{"name", m.Name})
  7243. }
  7244. if m.AllowEmptyValue != false {
  7245. info = append(info, yaml.MapItem{"allowEmptyValue", m.AllowEmptyValue})
  7246. }
  7247. if m.Type != "" {
  7248. info = append(info, yaml.MapItem{"type", m.Type})
  7249. }
  7250. if m.Format != "" {
  7251. info = append(info, yaml.MapItem{"format", m.Format})
  7252. }
  7253. if m.Items != nil {
  7254. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  7255. }
  7256. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7257. if m.CollectionFormat != "" {
  7258. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  7259. }
  7260. if m.Default != nil {
  7261. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  7262. }
  7263. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7264. if m.Maximum != 0.0 {
  7265. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  7266. }
  7267. if m.ExclusiveMaximum != false {
  7268. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  7269. }
  7270. if m.Minimum != 0.0 {
  7271. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  7272. }
  7273. if m.ExclusiveMinimum != false {
  7274. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  7275. }
  7276. if m.MaxLength != 0 {
  7277. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  7278. }
  7279. if m.MinLength != 0 {
  7280. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  7281. }
  7282. if m.Pattern != "" {
  7283. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  7284. }
  7285. if m.MaxItems != 0 {
  7286. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  7287. }
  7288. if m.MinItems != 0 {
  7289. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  7290. }
  7291. if m.UniqueItems != false {
  7292. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  7293. }
  7294. if len(m.Enum) != 0 {
  7295. items := make([]interface{}, 0)
  7296. for _, item := range m.Enum {
  7297. items = append(items, item.ToRawInfo())
  7298. }
  7299. info = append(info, yaml.MapItem{"enum", items})
  7300. }
  7301. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7302. if m.MultipleOf != 0.0 {
  7303. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  7304. }
  7305. if m.VendorExtension != nil {
  7306. for _, item := range m.VendorExtension {
  7307. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7308. }
  7309. }
  7310. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7311. return info
  7312. }
  7313. // ToRawInfo returns a description of Header suitable for JSON or YAML export.
  7314. func (m *Header) ToRawInfo() interface{} {
  7315. info := yaml.MapSlice{}
  7316. if m.Type != "" {
  7317. info = append(info, yaml.MapItem{"type", m.Type})
  7318. }
  7319. if m.Format != "" {
  7320. info = append(info, yaml.MapItem{"format", m.Format})
  7321. }
  7322. if m.Items != nil {
  7323. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  7324. }
  7325. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7326. if m.CollectionFormat != "" {
  7327. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  7328. }
  7329. if m.Default != nil {
  7330. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  7331. }
  7332. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7333. if m.Maximum != 0.0 {
  7334. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  7335. }
  7336. if m.ExclusiveMaximum != false {
  7337. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  7338. }
  7339. if m.Minimum != 0.0 {
  7340. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  7341. }
  7342. if m.ExclusiveMinimum != false {
  7343. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  7344. }
  7345. if m.MaxLength != 0 {
  7346. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  7347. }
  7348. if m.MinLength != 0 {
  7349. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  7350. }
  7351. if m.Pattern != "" {
  7352. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  7353. }
  7354. if m.MaxItems != 0 {
  7355. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  7356. }
  7357. if m.MinItems != 0 {
  7358. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  7359. }
  7360. if m.UniqueItems != false {
  7361. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  7362. }
  7363. if len(m.Enum) != 0 {
  7364. items := make([]interface{}, 0)
  7365. for _, item := range m.Enum {
  7366. items = append(items, item.ToRawInfo())
  7367. }
  7368. info = append(info, yaml.MapItem{"enum", items})
  7369. }
  7370. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7371. if m.MultipleOf != 0.0 {
  7372. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  7373. }
  7374. if m.Description != "" {
  7375. info = append(info, yaml.MapItem{"description", m.Description})
  7376. }
  7377. if m.VendorExtension != nil {
  7378. for _, item := range m.VendorExtension {
  7379. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7380. }
  7381. }
  7382. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7383. return info
  7384. }
  7385. // ToRawInfo returns a description of HeaderParameterSubSchema suitable for JSON or YAML export.
  7386. func (m *HeaderParameterSubSchema) ToRawInfo() interface{} {
  7387. info := yaml.MapSlice{}
  7388. if m.Required != false {
  7389. info = append(info, yaml.MapItem{"required", m.Required})
  7390. }
  7391. if m.In != "" {
  7392. info = append(info, yaml.MapItem{"in", m.In})
  7393. }
  7394. if m.Description != "" {
  7395. info = append(info, yaml.MapItem{"description", m.Description})
  7396. }
  7397. if m.Name != "" {
  7398. info = append(info, yaml.MapItem{"name", m.Name})
  7399. }
  7400. if m.Type != "" {
  7401. info = append(info, yaml.MapItem{"type", m.Type})
  7402. }
  7403. if m.Format != "" {
  7404. info = append(info, yaml.MapItem{"format", m.Format})
  7405. }
  7406. if m.Items != nil {
  7407. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  7408. }
  7409. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7410. if m.CollectionFormat != "" {
  7411. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  7412. }
  7413. if m.Default != nil {
  7414. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  7415. }
  7416. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7417. if m.Maximum != 0.0 {
  7418. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  7419. }
  7420. if m.ExclusiveMaximum != false {
  7421. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  7422. }
  7423. if m.Minimum != 0.0 {
  7424. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  7425. }
  7426. if m.ExclusiveMinimum != false {
  7427. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  7428. }
  7429. if m.MaxLength != 0 {
  7430. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  7431. }
  7432. if m.MinLength != 0 {
  7433. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  7434. }
  7435. if m.Pattern != "" {
  7436. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  7437. }
  7438. if m.MaxItems != 0 {
  7439. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  7440. }
  7441. if m.MinItems != 0 {
  7442. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  7443. }
  7444. if m.UniqueItems != false {
  7445. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  7446. }
  7447. if len(m.Enum) != 0 {
  7448. items := make([]interface{}, 0)
  7449. for _, item := range m.Enum {
  7450. items = append(items, item.ToRawInfo())
  7451. }
  7452. info = append(info, yaml.MapItem{"enum", items})
  7453. }
  7454. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7455. if m.MultipleOf != 0.0 {
  7456. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  7457. }
  7458. if m.VendorExtension != nil {
  7459. for _, item := range m.VendorExtension {
  7460. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7461. }
  7462. }
  7463. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7464. return info
  7465. }
  7466. // ToRawInfo returns a description of Headers suitable for JSON or YAML export.
  7467. func (m *Headers) ToRawInfo() interface{} {
  7468. info := yaml.MapSlice{}
  7469. if m.AdditionalProperties != nil {
  7470. for _, item := range m.AdditionalProperties {
  7471. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7472. }
  7473. }
  7474. // &{Name:additionalProperties Type:NamedHeader StringEnumValues:[] MapType:Header Repeated:true Pattern: Implicit:true Description:}
  7475. return info
  7476. }
  7477. // ToRawInfo returns a description of Info suitable for JSON or YAML export.
  7478. func (m *Info) ToRawInfo() interface{} {
  7479. info := yaml.MapSlice{}
  7480. if m.Title != "" {
  7481. info = append(info, yaml.MapItem{"title", m.Title})
  7482. }
  7483. if m.Version != "" {
  7484. info = append(info, yaml.MapItem{"version", m.Version})
  7485. }
  7486. if m.Description != "" {
  7487. info = append(info, yaml.MapItem{"description", m.Description})
  7488. }
  7489. if m.TermsOfService != "" {
  7490. info = append(info, yaml.MapItem{"termsOfService", m.TermsOfService})
  7491. }
  7492. if m.Contact != nil {
  7493. info = append(info, yaml.MapItem{"contact", m.Contact.ToRawInfo()})
  7494. }
  7495. // &{Name:contact Type:Contact StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7496. if m.License != nil {
  7497. info = append(info, yaml.MapItem{"license", m.License.ToRawInfo()})
  7498. }
  7499. // &{Name:license Type:License StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7500. if m.VendorExtension != nil {
  7501. for _, item := range m.VendorExtension {
  7502. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7503. }
  7504. }
  7505. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7506. return info
  7507. }
  7508. // ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export.
  7509. func (m *ItemsItem) ToRawInfo() interface{} {
  7510. info := yaml.MapSlice{}
  7511. if len(m.Schema) != 0 {
  7512. items := make([]interface{}, 0)
  7513. for _, item := range m.Schema {
  7514. items = append(items, item.ToRawInfo())
  7515. }
  7516. info = append(info, yaml.MapItem{"schema", items})
  7517. }
  7518. // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7519. return info
  7520. }
  7521. // ToRawInfo returns a description of JsonReference suitable for JSON or YAML export.
  7522. func (m *JsonReference) ToRawInfo() interface{} {
  7523. info := yaml.MapSlice{}
  7524. if m.XRef != "" {
  7525. info = append(info, yaml.MapItem{"$ref", m.XRef})
  7526. }
  7527. if m.Description != "" {
  7528. info = append(info, yaml.MapItem{"description", m.Description})
  7529. }
  7530. return info
  7531. }
  7532. // ToRawInfo returns a description of License suitable for JSON or YAML export.
  7533. func (m *License) ToRawInfo() interface{} {
  7534. info := yaml.MapSlice{}
  7535. if m.Name != "" {
  7536. info = append(info, yaml.MapItem{"name", m.Name})
  7537. }
  7538. if m.Url != "" {
  7539. info = append(info, yaml.MapItem{"url", m.Url})
  7540. }
  7541. if m.VendorExtension != nil {
  7542. for _, item := range m.VendorExtension {
  7543. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7544. }
  7545. }
  7546. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7547. return info
  7548. }
  7549. // ToRawInfo returns a description of NamedAny suitable for JSON or YAML export.
  7550. func (m *NamedAny) ToRawInfo() interface{} {
  7551. info := yaml.MapSlice{}
  7552. if m.Name != "" {
  7553. info = append(info, yaml.MapItem{"name", m.Name})
  7554. }
  7555. // &{Name:value Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7556. return info
  7557. }
  7558. // ToRawInfo returns a description of NamedHeader suitable for JSON or YAML export.
  7559. func (m *NamedHeader) ToRawInfo() interface{} {
  7560. info := yaml.MapSlice{}
  7561. if m.Name != "" {
  7562. info = append(info, yaml.MapItem{"name", m.Name})
  7563. }
  7564. // &{Name:value Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7565. return info
  7566. }
  7567. // ToRawInfo returns a description of NamedParameter suitable for JSON or YAML export.
  7568. func (m *NamedParameter) ToRawInfo() interface{} {
  7569. info := yaml.MapSlice{}
  7570. if m.Name != "" {
  7571. info = append(info, yaml.MapItem{"name", m.Name})
  7572. }
  7573. // &{Name:value Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7574. return info
  7575. }
  7576. // ToRawInfo returns a description of NamedPathItem suitable for JSON or YAML export.
  7577. func (m *NamedPathItem) ToRawInfo() interface{} {
  7578. info := yaml.MapSlice{}
  7579. if m.Name != "" {
  7580. info = append(info, yaml.MapItem{"name", m.Name})
  7581. }
  7582. // &{Name:value Type:PathItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7583. return info
  7584. }
  7585. // ToRawInfo returns a description of NamedResponse suitable for JSON or YAML export.
  7586. func (m *NamedResponse) ToRawInfo() interface{} {
  7587. info := yaml.MapSlice{}
  7588. if m.Name != "" {
  7589. info = append(info, yaml.MapItem{"name", m.Name})
  7590. }
  7591. // &{Name:value Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7592. return info
  7593. }
  7594. // ToRawInfo returns a description of NamedResponseValue suitable for JSON or YAML export.
  7595. func (m *NamedResponseValue) ToRawInfo() interface{} {
  7596. info := yaml.MapSlice{}
  7597. if m.Name != "" {
  7598. info = append(info, yaml.MapItem{"name", m.Name})
  7599. }
  7600. // &{Name:value Type:ResponseValue StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7601. return info
  7602. }
  7603. // ToRawInfo returns a description of NamedSchema suitable for JSON or YAML export.
  7604. func (m *NamedSchema) ToRawInfo() interface{} {
  7605. info := yaml.MapSlice{}
  7606. if m.Name != "" {
  7607. info = append(info, yaml.MapItem{"name", m.Name})
  7608. }
  7609. // &{Name:value Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7610. return info
  7611. }
  7612. // ToRawInfo returns a description of NamedSecurityDefinitionsItem suitable for JSON or YAML export.
  7613. func (m *NamedSecurityDefinitionsItem) ToRawInfo() interface{} {
  7614. info := yaml.MapSlice{}
  7615. if m.Name != "" {
  7616. info = append(info, yaml.MapItem{"name", m.Name})
  7617. }
  7618. // &{Name:value Type:SecurityDefinitionsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7619. return info
  7620. }
  7621. // ToRawInfo returns a description of NamedString suitable for JSON or YAML export.
  7622. func (m *NamedString) ToRawInfo() interface{} {
  7623. info := yaml.MapSlice{}
  7624. if m.Name != "" {
  7625. info = append(info, yaml.MapItem{"name", m.Name})
  7626. }
  7627. if m.Value != "" {
  7628. info = append(info, yaml.MapItem{"value", m.Value})
  7629. }
  7630. return info
  7631. }
  7632. // ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export.
  7633. func (m *NamedStringArray) ToRawInfo() interface{} {
  7634. info := yaml.MapSlice{}
  7635. if m.Name != "" {
  7636. info = append(info, yaml.MapItem{"name", m.Name})
  7637. }
  7638. // &{Name:value Type:StringArray StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value}
  7639. return info
  7640. }
  7641. // ToRawInfo returns a description of NonBodyParameter suitable for JSON or YAML export.
  7642. func (m *NonBodyParameter) ToRawInfo() interface{} {
  7643. // ONE OF WRAPPER
  7644. // NonBodyParameter
  7645. // {Name:headerParameterSubSchema Type:HeaderParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7646. v0 := m.GetHeaderParameterSubSchema()
  7647. if v0 != nil {
  7648. return v0.ToRawInfo()
  7649. }
  7650. // {Name:formDataParameterSubSchema Type:FormDataParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7651. v1 := m.GetFormDataParameterSubSchema()
  7652. if v1 != nil {
  7653. return v1.ToRawInfo()
  7654. }
  7655. // {Name:queryParameterSubSchema Type:QueryParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7656. v2 := m.GetQueryParameterSubSchema()
  7657. if v2 != nil {
  7658. return v2.ToRawInfo()
  7659. }
  7660. // {Name:pathParameterSubSchema Type:PathParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7661. v3 := m.GetPathParameterSubSchema()
  7662. if v3 != nil {
  7663. return v3.ToRawInfo()
  7664. }
  7665. return nil
  7666. }
  7667. // ToRawInfo returns a description of Oauth2AccessCodeSecurity suitable for JSON or YAML export.
  7668. func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} {
  7669. info := yaml.MapSlice{}
  7670. if m.Type != "" {
  7671. info = append(info, yaml.MapItem{"type", m.Type})
  7672. }
  7673. if m.Flow != "" {
  7674. info = append(info, yaml.MapItem{"flow", m.Flow})
  7675. }
  7676. if m.Scopes != nil {
  7677. info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()})
  7678. }
  7679. // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7680. if m.AuthorizationUrl != "" {
  7681. info = append(info, yaml.MapItem{"authorizationUrl", m.AuthorizationUrl})
  7682. }
  7683. if m.TokenUrl != "" {
  7684. info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl})
  7685. }
  7686. if m.Description != "" {
  7687. info = append(info, yaml.MapItem{"description", m.Description})
  7688. }
  7689. if m.VendorExtension != nil {
  7690. for _, item := range m.VendorExtension {
  7691. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7692. }
  7693. }
  7694. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7695. return info
  7696. }
  7697. // ToRawInfo returns a description of Oauth2ApplicationSecurity suitable for JSON or YAML export.
  7698. func (m *Oauth2ApplicationSecurity) ToRawInfo() interface{} {
  7699. info := yaml.MapSlice{}
  7700. if m.Type != "" {
  7701. info = append(info, yaml.MapItem{"type", m.Type})
  7702. }
  7703. if m.Flow != "" {
  7704. info = append(info, yaml.MapItem{"flow", m.Flow})
  7705. }
  7706. if m.Scopes != nil {
  7707. info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()})
  7708. }
  7709. // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7710. if m.TokenUrl != "" {
  7711. info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl})
  7712. }
  7713. if m.Description != "" {
  7714. info = append(info, yaml.MapItem{"description", m.Description})
  7715. }
  7716. if m.VendorExtension != nil {
  7717. for _, item := range m.VendorExtension {
  7718. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7719. }
  7720. }
  7721. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7722. return info
  7723. }
  7724. // ToRawInfo returns a description of Oauth2ImplicitSecurity suitable for JSON or YAML export.
  7725. func (m *Oauth2ImplicitSecurity) ToRawInfo() interface{} {
  7726. info := yaml.MapSlice{}
  7727. if m.Type != "" {
  7728. info = append(info, yaml.MapItem{"type", m.Type})
  7729. }
  7730. if m.Flow != "" {
  7731. info = append(info, yaml.MapItem{"flow", m.Flow})
  7732. }
  7733. if m.Scopes != nil {
  7734. info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()})
  7735. }
  7736. // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7737. if m.AuthorizationUrl != "" {
  7738. info = append(info, yaml.MapItem{"authorizationUrl", m.AuthorizationUrl})
  7739. }
  7740. if m.Description != "" {
  7741. info = append(info, yaml.MapItem{"description", m.Description})
  7742. }
  7743. if m.VendorExtension != nil {
  7744. for _, item := range m.VendorExtension {
  7745. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7746. }
  7747. }
  7748. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7749. return info
  7750. }
  7751. // ToRawInfo returns a description of Oauth2PasswordSecurity suitable for JSON or YAML export.
  7752. func (m *Oauth2PasswordSecurity) ToRawInfo() interface{} {
  7753. info := yaml.MapSlice{}
  7754. if m.Type != "" {
  7755. info = append(info, yaml.MapItem{"type", m.Type})
  7756. }
  7757. if m.Flow != "" {
  7758. info = append(info, yaml.MapItem{"flow", m.Flow})
  7759. }
  7760. if m.Scopes != nil {
  7761. info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()})
  7762. }
  7763. // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7764. if m.TokenUrl != "" {
  7765. info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl})
  7766. }
  7767. if m.Description != "" {
  7768. info = append(info, yaml.MapItem{"description", m.Description})
  7769. }
  7770. if m.VendorExtension != nil {
  7771. for _, item := range m.VendorExtension {
  7772. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7773. }
  7774. }
  7775. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7776. return info
  7777. }
  7778. // ToRawInfo returns a description of Oauth2Scopes suitable for JSON or YAML export.
  7779. func (m *Oauth2Scopes) ToRawInfo() interface{} {
  7780. info := yaml.MapSlice{}
  7781. // &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:}
  7782. return info
  7783. }
  7784. // ToRawInfo returns a description of Operation suitable for JSON or YAML export.
  7785. func (m *Operation) ToRawInfo() interface{} {
  7786. info := yaml.MapSlice{}
  7787. if len(m.Tags) != 0 {
  7788. info = append(info, yaml.MapItem{"tags", m.Tags})
  7789. }
  7790. if m.Summary != "" {
  7791. info = append(info, yaml.MapItem{"summary", m.Summary})
  7792. }
  7793. if m.Description != "" {
  7794. info = append(info, yaml.MapItem{"description", m.Description})
  7795. }
  7796. if m.ExternalDocs != nil {
  7797. info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()})
  7798. }
  7799. // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7800. if m.OperationId != "" {
  7801. info = append(info, yaml.MapItem{"operationId", m.OperationId})
  7802. }
  7803. if len(m.Produces) != 0 {
  7804. info = append(info, yaml.MapItem{"produces", m.Produces})
  7805. }
  7806. if len(m.Consumes) != 0 {
  7807. info = append(info, yaml.MapItem{"consumes", m.Consumes})
  7808. }
  7809. if len(m.Parameters) != 0 {
  7810. items := make([]interface{}, 0)
  7811. for _, item := range m.Parameters {
  7812. items = append(items, item.ToRawInfo())
  7813. }
  7814. info = append(info, yaml.MapItem{"parameters", items})
  7815. }
  7816. // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.}
  7817. if m.Responses != nil {
  7818. info = append(info, yaml.MapItem{"responses", m.Responses.ToRawInfo()})
  7819. }
  7820. // &{Name:responses Type:Responses StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7821. if len(m.Schemes) != 0 {
  7822. info = append(info, yaml.MapItem{"schemes", m.Schemes})
  7823. }
  7824. if m.Deprecated != false {
  7825. info = append(info, yaml.MapItem{"deprecated", m.Deprecated})
  7826. }
  7827. if len(m.Security) != 0 {
  7828. items := make([]interface{}, 0)
  7829. for _, item := range m.Security {
  7830. items = append(items, item.ToRawInfo())
  7831. }
  7832. info = append(info, yaml.MapItem{"security", items})
  7833. }
  7834. // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  7835. if m.VendorExtension != nil {
  7836. for _, item := range m.VendorExtension {
  7837. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7838. }
  7839. }
  7840. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7841. return info
  7842. }
  7843. // ToRawInfo returns a description of Parameter suitable for JSON or YAML export.
  7844. func (m *Parameter) ToRawInfo() interface{} {
  7845. // ONE OF WRAPPER
  7846. // Parameter
  7847. // {Name:bodyParameter Type:BodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7848. v0 := m.GetBodyParameter()
  7849. if v0 != nil {
  7850. return v0.ToRawInfo()
  7851. }
  7852. // {Name:nonBodyParameter Type:NonBodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7853. v1 := m.GetNonBodyParameter()
  7854. if v1 != nil {
  7855. return v1.ToRawInfo()
  7856. }
  7857. return nil
  7858. }
  7859. // ToRawInfo returns a description of ParameterDefinitions suitable for JSON or YAML export.
  7860. func (m *ParameterDefinitions) ToRawInfo() interface{} {
  7861. info := yaml.MapSlice{}
  7862. if m.AdditionalProperties != nil {
  7863. for _, item := range m.AdditionalProperties {
  7864. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7865. }
  7866. }
  7867. // &{Name:additionalProperties Type:NamedParameter StringEnumValues:[] MapType:Parameter Repeated:true Pattern: Implicit:true Description:}
  7868. return info
  7869. }
  7870. // ToRawInfo returns a description of ParametersItem suitable for JSON or YAML export.
  7871. func (m *ParametersItem) ToRawInfo() interface{} {
  7872. // ONE OF WRAPPER
  7873. // ParametersItem
  7874. // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7875. v0 := m.GetParameter()
  7876. if v0 != nil {
  7877. return v0.ToRawInfo()
  7878. }
  7879. // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7880. v1 := m.GetJsonReference()
  7881. if v1 != nil {
  7882. return v1.ToRawInfo()
  7883. }
  7884. return nil
  7885. }
  7886. // ToRawInfo returns a description of PathItem suitable for JSON or YAML export.
  7887. func (m *PathItem) ToRawInfo() interface{} {
  7888. info := yaml.MapSlice{}
  7889. if m.XRef != "" {
  7890. info = append(info, yaml.MapItem{"$ref", m.XRef})
  7891. }
  7892. if m.Get != nil {
  7893. info = append(info, yaml.MapItem{"get", m.Get.ToRawInfo()})
  7894. }
  7895. // &{Name:get Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7896. if m.Put != nil {
  7897. info = append(info, yaml.MapItem{"put", m.Put.ToRawInfo()})
  7898. }
  7899. // &{Name:put Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7900. if m.Post != nil {
  7901. info = append(info, yaml.MapItem{"post", m.Post.ToRawInfo()})
  7902. }
  7903. // &{Name:post Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7904. if m.Delete != nil {
  7905. info = append(info, yaml.MapItem{"delete", m.Delete.ToRawInfo()})
  7906. }
  7907. // &{Name:delete Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7908. if m.Options != nil {
  7909. info = append(info, yaml.MapItem{"options", m.Options.ToRawInfo()})
  7910. }
  7911. // &{Name:options Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7912. if m.Head != nil {
  7913. info = append(info, yaml.MapItem{"head", m.Head.ToRawInfo()})
  7914. }
  7915. // &{Name:head Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7916. if m.Patch != nil {
  7917. info = append(info, yaml.MapItem{"patch", m.Patch.ToRawInfo()})
  7918. }
  7919. // &{Name:patch Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7920. if len(m.Parameters) != 0 {
  7921. items := make([]interface{}, 0)
  7922. for _, item := range m.Parameters {
  7923. items = append(items, item.ToRawInfo())
  7924. }
  7925. info = append(info, yaml.MapItem{"parameters", items})
  7926. }
  7927. // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.}
  7928. if m.VendorExtension != nil {
  7929. for _, item := range m.VendorExtension {
  7930. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  7931. }
  7932. }
  7933. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  7934. return info
  7935. }
  7936. // ToRawInfo returns a description of PathParameterSubSchema suitable for JSON or YAML export.
  7937. func (m *PathParameterSubSchema) ToRawInfo() interface{} {
  7938. info := yaml.MapSlice{}
  7939. if m.Required != false {
  7940. info = append(info, yaml.MapItem{"required", m.Required})
  7941. }
  7942. if m.In != "" {
  7943. info = append(info, yaml.MapItem{"in", m.In})
  7944. }
  7945. if m.Description != "" {
  7946. info = append(info, yaml.MapItem{"description", m.Description})
  7947. }
  7948. if m.Name != "" {
  7949. info = append(info, yaml.MapItem{"name", m.Name})
  7950. }
  7951. if m.Type != "" {
  7952. info = append(info, yaml.MapItem{"type", m.Type})
  7953. }
  7954. if m.Format != "" {
  7955. info = append(info, yaml.MapItem{"format", m.Format})
  7956. }
  7957. if m.Items != nil {
  7958. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  7959. }
  7960. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7961. if m.CollectionFormat != "" {
  7962. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  7963. }
  7964. if m.Default != nil {
  7965. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  7966. }
  7967. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  7968. if m.Maximum != 0.0 {
  7969. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  7970. }
  7971. if m.ExclusiveMaximum != false {
  7972. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  7973. }
  7974. if m.Minimum != 0.0 {
  7975. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  7976. }
  7977. if m.ExclusiveMinimum != false {
  7978. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  7979. }
  7980. if m.MaxLength != 0 {
  7981. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  7982. }
  7983. if m.MinLength != 0 {
  7984. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  7985. }
  7986. if m.Pattern != "" {
  7987. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  7988. }
  7989. if m.MaxItems != 0 {
  7990. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  7991. }
  7992. if m.MinItems != 0 {
  7993. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  7994. }
  7995. if m.UniqueItems != false {
  7996. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  7997. }
  7998. if len(m.Enum) != 0 {
  7999. items := make([]interface{}, 0)
  8000. for _, item := range m.Enum {
  8001. items = append(items, item.ToRawInfo())
  8002. }
  8003. info = append(info, yaml.MapItem{"enum", items})
  8004. }
  8005. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  8006. if m.MultipleOf != 0.0 {
  8007. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  8008. }
  8009. if m.VendorExtension != nil {
  8010. for _, item := range m.VendorExtension {
  8011. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8012. }
  8013. }
  8014. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8015. return info
  8016. }
  8017. // ToRawInfo returns a description of Paths suitable for JSON or YAML export.
  8018. func (m *Paths) ToRawInfo() interface{} {
  8019. info := yaml.MapSlice{}
  8020. if m.VendorExtension != nil {
  8021. for _, item := range m.VendorExtension {
  8022. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8023. }
  8024. }
  8025. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8026. if m.Path != nil {
  8027. for _, item := range m.Path {
  8028. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8029. }
  8030. }
  8031. // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^/ Implicit:true Description:}
  8032. return info
  8033. }
  8034. // ToRawInfo returns a description of PrimitivesItems suitable for JSON or YAML export.
  8035. func (m *PrimitivesItems) ToRawInfo() interface{} {
  8036. info := yaml.MapSlice{}
  8037. if m.Type != "" {
  8038. info = append(info, yaml.MapItem{"type", m.Type})
  8039. }
  8040. if m.Format != "" {
  8041. info = append(info, yaml.MapItem{"format", m.Format})
  8042. }
  8043. if m.Items != nil {
  8044. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  8045. }
  8046. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8047. if m.CollectionFormat != "" {
  8048. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  8049. }
  8050. if m.Default != nil {
  8051. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  8052. }
  8053. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8054. if m.Maximum != 0.0 {
  8055. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  8056. }
  8057. if m.ExclusiveMaximum != false {
  8058. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  8059. }
  8060. if m.Minimum != 0.0 {
  8061. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  8062. }
  8063. if m.ExclusiveMinimum != false {
  8064. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  8065. }
  8066. if m.MaxLength != 0 {
  8067. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  8068. }
  8069. if m.MinLength != 0 {
  8070. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  8071. }
  8072. if m.Pattern != "" {
  8073. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  8074. }
  8075. if m.MaxItems != 0 {
  8076. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  8077. }
  8078. if m.MinItems != 0 {
  8079. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  8080. }
  8081. if m.UniqueItems != false {
  8082. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  8083. }
  8084. if len(m.Enum) != 0 {
  8085. items := make([]interface{}, 0)
  8086. for _, item := range m.Enum {
  8087. items = append(items, item.ToRawInfo())
  8088. }
  8089. info = append(info, yaml.MapItem{"enum", items})
  8090. }
  8091. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  8092. if m.MultipleOf != 0.0 {
  8093. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  8094. }
  8095. if m.VendorExtension != nil {
  8096. for _, item := range m.VendorExtension {
  8097. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8098. }
  8099. }
  8100. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8101. return info
  8102. }
  8103. // ToRawInfo returns a description of Properties suitable for JSON or YAML export.
  8104. func (m *Properties) ToRawInfo() interface{} {
  8105. info := yaml.MapSlice{}
  8106. if m.AdditionalProperties != nil {
  8107. for _, item := range m.AdditionalProperties {
  8108. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8109. }
  8110. }
  8111. // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:}
  8112. return info
  8113. }
  8114. // ToRawInfo returns a description of QueryParameterSubSchema suitable for JSON or YAML export.
  8115. func (m *QueryParameterSubSchema) ToRawInfo() interface{} {
  8116. info := yaml.MapSlice{}
  8117. if m.Required != false {
  8118. info = append(info, yaml.MapItem{"required", m.Required})
  8119. }
  8120. if m.In != "" {
  8121. info = append(info, yaml.MapItem{"in", m.In})
  8122. }
  8123. if m.Description != "" {
  8124. info = append(info, yaml.MapItem{"description", m.Description})
  8125. }
  8126. if m.Name != "" {
  8127. info = append(info, yaml.MapItem{"name", m.Name})
  8128. }
  8129. if m.AllowEmptyValue != false {
  8130. info = append(info, yaml.MapItem{"allowEmptyValue", m.AllowEmptyValue})
  8131. }
  8132. if m.Type != "" {
  8133. info = append(info, yaml.MapItem{"type", m.Type})
  8134. }
  8135. if m.Format != "" {
  8136. info = append(info, yaml.MapItem{"format", m.Format})
  8137. }
  8138. if m.Items != nil {
  8139. info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()})
  8140. }
  8141. // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8142. if m.CollectionFormat != "" {
  8143. info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat})
  8144. }
  8145. if m.Default != nil {
  8146. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  8147. }
  8148. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8149. if m.Maximum != 0.0 {
  8150. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  8151. }
  8152. if m.ExclusiveMaximum != false {
  8153. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  8154. }
  8155. if m.Minimum != 0.0 {
  8156. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  8157. }
  8158. if m.ExclusiveMinimum != false {
  8159. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  8160. }
  8161. if m.MaxLength != 0 {
  8162. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  8163. }
  8164. if m.MinLength != 0 {
  8165. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  8166. }
  8167. if m.Pattern != "" {
  8168. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  8169. }
  8170. if m.MaxItems != 0 {
  8171. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  8172. }
  8173. if m.MinItems != 0 {
  8174. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  8175. }
  8176. if m.UniqueItems != false {
  8177. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  8178. }
  8179. if len(m.Enum) != 0 {
  8180. items := make([]interface{}, 0)
  8181. for _, item := range m.Enum {
  8182. items = append(items, item.ToRawInfo())
  8183. }
  8184. info = append(info, yaml.MapItem{"enum", items})
  8185. }
  8186. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  8187. if m.MultipleOf != 0.0 {
  8188. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  8189. }
  8190. if m.VendorExtension != nil {
  8191. for _, item := range m.VendorExtension {
  8192. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8193. }
  8194. }
  8195. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8196. return info
  8197. }
  8198. // ToRawInfo returns a description of Response suitable for JSON or YAML export.
  8199. func (m *Response) ToRawInfo() interface{} {
  8200. info := yaml.MapSlice{}
  8201. if m.Description != "" {
  8202. info = append(info, yaml.MapItem{"description", m.Description})
  8203. }
  8204. if m.Schema != nil {
  8205. info = append(info, yaml.MapItem{"schema", m.Schema.ToRawInfo()})
  8206. }
  8207. // &{Name:schema Type:SchemaItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8208. if m.Headers != nil {
  8209. info = append(info, yaml.MapItem{"headers", m.Headers.ToRawInfo()})
  8210. }
  8211. // &{Name:headers Type:Headers StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8212. if m.Examples != nil {
  8213. info = append(info, yaml.MapItem{"examples", m.Examples.ToRawInfo()})
  8214. }
  8215. // &{Name:examples Type:Examples StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8216. if m.VendorExtension != nil {
  8217. for _, item := range m.VendorExtension {
  8218. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8219. }
  8220. }
  8221. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8222. return info
  8223. }
  8224. // ToRawInfo returns a description of ResponseDefinitions suitable for JSON or YAML export.
  8225. func (m *ResponseDefinitions) ToRawInfo() interface{} {
  8226. info := yaml.MapSlice{}
  8227. if m.AdditionalProperties != nil {
  8228. for _, item := range m.AdditionalProperties {
  8229. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8230. }
  8231. }
  8232. // &{Name:additionalProperties Type:NamedResponse StringEnumValues:[] MapType:Response Repeated:true Pattern: Implicit:true Description:}
  8233. return info
  8234. }
  8235. // ToRawInfo returns a description of ResponseValue suitable for JSON or YAML export.
  8236. func (m *ResponseValue) ToRawInfo() interface{} {
  8237. // ONE OF WRAPPER
  8238. // ResponseValue
  8239. // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8240. v0 := m.GetResponse()
  8241. if v0 != nil {
  8242. return v0.ToRawInfo()
  8243. }
  8244. // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8245. v1 := m.GetJsonReference()
  8246. if v1 != nil {
  8247. return v1.ToRawInfo()
  8248. }
  8249. return nil
  8250. }
  8251. // ToRawInfo returns a description of Responses suitable for JSON or YAML export.
  8252. func (m *Responses) ToRawInfo() interface{} {
  8253. info := yaml.MapSlice{}
  8254. if m.ResponseCode != nil {
  8255. for _, item := range m.ResponseCode {
  8256. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8257. }
  8258. }
  8259. // &{Name:ResponseCode Type:NamedResponseValue StringEnumValues:[] MapType:ResponseValue Repeated:true Pattern:^([0-9]{3})$|^(default)$ Implicit:true Description:}
  8260. if m.VendorExtension != nil {
  8261. for _, item := range m.VendorExtension {
  8262. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8263. }
  8264. }
  8265. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8266. return info
  8267. }
  8268. // ToRawInfo returns a description of Schema suitable for JSON or YAML export.
  8269. func (m *Schema) ToRawInfo() interface{} {
  8270. info := yaml.MapSlice{}
  8271. if m.XRef != "" {
  8272. info = append(info, yaml.MapItem{"$ref", m.XRef})
  8273. }
  8274. if m.Format != "" {
  8275. info = append(info, yaml.MapItem{"format", m.Format})
  8276. }
  8277. if m.Title != "" {
  8278. info = append(info, yaml.MapItem{"title", m.Title})
  8279. }
  8280. if m.Description != "" {
  8281. info = append(info, yaml.MapItem{"description", m.Description})
  8282. }
  8283. if m.Default != nil {
  8284. info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()})
  8285. }
  8286. // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8287. if m.MultipleOf != 0.0 {
  8288. info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf})
  8289. }
  8290. if m.Maximum != 0.0 {
  8291. info = append(info, yaml.MapItem{"maximum", m.Maximum})
  8292. }
  8293. if m.ExclusiveMaximum != false {
  8294. info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum})
  8295. }
  8296. if m.Minimum != 0.0 {
  8297. info = append(info, yaml.MapItem{"minimum", m.Minimum})
  8298. }
  8299. if m.ExclusiveMinimum != false {
  8300. info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum})
  8301. }
  8302. if m.MaxLength != 0 {
  8303. info = append(info, yaml.MapItem{"maxLength", m.MaxLength})
  8304. }
  8305. if m.MinLength != 0 {
  8306. info = append(info, yaml.MapItem{"minLength", m.MinLength})
  8307. }
  8308. if m.Pattern != "" {
  8309. info = append(info, yaml.MapItem{"pattern", m.Pattern})
  8310. }
  8311. if m.MaxItems != 0 {
  8312. info = append(info, yaml.MapItem{"maxItems", m.MaxItems})
  8313. }
  8314. if m.MinItems != 0 {
  8315. info = append(info, yaml.MapItem{"minItems", m.MinItems})
  8316. }
  8317. if m.UniqueItems != false {
  8318. info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems})
  8319. }
  8320. if m.MaxProperties != 0 {
  8321. info = append(info, yaml.MapItem{"maxProperties", m.MaxProperties})
  8322. }
  8323. if m.MinProperties != 0 {
  8324. info = append(info, yaml.MapItem{"minProperties", m.MinProperties})
  8325. }
  8326. if len(m.Required) != 0 {
  8327. info = append(info, yaml.MapItem{"required", m.Required})
  8328. }
  8329. if len(m.Enum) != 0 {
  8330. items := make([]interface{}, 0)
  8331. for _, item := range m.Enum {
  8332. items = append(items, item.ToRawInfo())
  8333. }
  8334. info = append(info, yaml.MapItem{"enum", items})
  8335. }
  8336. // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  8337. if m.AdditionalProperties != nil {
  8338. info = append(info, yaml.MapItem{"additionalProperties", m.AdditionalProperties.ToRawInfo()})
  8339. }
  8340. // &{Name:additionalProperties Type:AdditionalPropertiesItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8341. if m.Type != nil {
  8342. if len(m.Type.Value) == 1 {
  8343. info = append(info, yaml.MapItem{"type", m.Type.Value[0]})
  8344. } else {
  8345. info = append(info, yaml.MapItem{"type", m.Type.Value})
  8346. }
  8347. }
  8348. // &{Name:type Type:TypeItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8349. if m.Items != nil {
  8350. items := make([]interface{}, 0)
  8351. for _, item := range m.Items.Schema {
  8352. items = append(items, item.ToRawInfo())
  8353. }
  8354. info = append(info, yaml.MapItem{"items", items[0]})
  8355. }
  8356. // &{Name:items Type:ItemsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8357. if len(m.AllOf) != 0 {
  8358. items := make([]interface{}, 0)
  8359. for _, item := range m.AllOf {
  8360. items = append(items, item.ToRawInfo())
  8361. }
  8362. info = append(info, yaml.MapItem{"allOf", items})
  8363. }
  8364. // &{Name:allOf Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:}
  8365. if m.Properties != nil {
  8366. info = append(info, yaml.MapItem{"properties", m.Properties.ToRawInfo()})
  8367. }
  8368. // &{Name:properties Type:Properties StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8369. if m.Discriminator != "" {
  8370. info = append(info, yaml.MapItem{"discriminator", m.Discriminator})
  8371. }
  8372. if m.ReadOnly != false {
  8373. info = append(info, yaml.MapItem{"readOnly", m.ReadOnly})
  8374. }
  8375. if m.Xml != nil {
  8376. info = append(info, yaml.MapItem{"xml", m.Xml.ToRawInfo()})
  8377. }
  8378. // &{Name:xml Type:Xml StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8379. if m.ExternalDocs != nil {
  8380. info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()})
  8381. }
  8382. // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8383. if m.Example != nil {
  8384. info = append(info, yaml.MapItem{"example", m.Example.ToRawInfo()})
  8385. }
  8386. // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8387. if m.VendorExtension != nil {
  8388. for _, item := range m.VendorExtension {
  8389. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8390. }
  8391. }
  8392. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8393. return info
  8394. }
  8395. // ToRawInfo returns a description of SchemaItem suitable for JSON or YAML export.
  8396. func (m *SchemaItem) ToRawInfo() interface{} {
  8397. // ONE OF WRAPPER
  8398. // SchemaItem
  8399. // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8400. v0 := m.GetSchema()
  8401. if v0 != nil {
  8402. return v0.ToRawInfo()
  8403. }
  8404. // {Name:fileSchema Type:FileSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8405. v1 := m.GetFileSchema()
  8406. if v1 != nil {
  8407. return v1.ToRawInfo()
  8408. }
  8409. return nil
  8410. }
  8411. // ToRawInfo returns a description of SecurityDefinitions suitable for JSON or YAML export.
  8412. func (m *SecurityDefinitions) ToRawInfo() interface{} {
  8413. info := yaml.MapSlice{}
  8414. if m.AdditionalProperties != nil {
  8415. for _, item := range m.AdditionalProperties {
  8416. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8417. }
  8418. }
  8419. // &{Name:additionalProperties Type:NamedSecurityDefinitionsItem StringEnumValues:[] MapType:SecurityDefinitionsItem Repeated:true Pattern: Implicit:true Description:}
  8420. return info
  8421. }
  8422. // ToRawInfo returns a description of SecurityDefinitionsItem suitable for JSON or YAML export.
  8423. func (m *SecurityDefinitionsItem) ToRawInfo() interface{} {
  8424. // ONE OF WRAPPER
  8425. // SecurityDefinitionsItem
  8426. // {Name:basicAuthenticationSecurity Type:BasicAuthenticationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8427. v0 := m.GetBasicAuthenticationSecurity()
  8428. if v0 != nil {
  8429. return v0.ToRawInfo()
  8430. }
  8431. // {Name:apiKeySecurity Type:ApiKeySecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8432. v1 := m.GetApiKeySecurity()
  8433. if v1 != nil {
  8434. return v1.ToRawInfo()
  8435. }
  8436. // {Name:oauth2ImplicitSecurity Type:Oauth2ImplicitSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8437. v2 := m.GetOauth2ImplicitSecurity()
  8438. if v2 != nil {
  8439. return v2.ToRawInfo()
  8440. }
  8441. // {Name:oauth2PasswordSecurity Type:Oauth2PasswordSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8442. v3 := m.GetOauth2PasswordSecurity()
  8443. if v3 != nil {
  8444. return v3.ToRawInfo()
  8445. }
  8446. // {Name:oauth2ApplicationSecurity Type:Oauth2ApplicationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8447. v4 := m.GetOauth2ApplicationSecurity()
  8448. if v4 != nil {
  8449. return v4.ToRawInfo()
  8450. }
  8451. // {Name:oauth2AccessCodeSecurity Type:Oauth2AccessCodeSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8452. v5 := m.GetOauth2AccessCodeSecurity()
  8453. if v5 != nil {
  8454. return v5.ToRawInfo()
  8455. }
  8456. return nil
  8457. }
  8458. // ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export.
  8459. func (m *SecurityRequirement) ToRawInfo() interface{} {
  8460. info := yaml.MapSlice{}
  8461. if m.AdditionalProperties != nil {
  8462. for _, item := range m.AdditionalProperties {
  8463. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8464. }
  8465. }
  8466. // &{Name:additionalProperties Type:NamedStringArray StringEnumValues:[] MapType:StringArray Repeated:true Pattern: Implicit:true Description:}
  8467. return info
  8468. }
  8469. // ToRawInfo returns a description of StringArray suitable for JSON or YAML export.
  8470. func (m *StringArray) ToRawInfo() interface{} {
  8471. return m.Value
  8472. }
  8473. // ToRawInfo returns a description of Tag suitable for JSON or YAML export.
  8474. func (m *Tag) ToRawInfo() interface{} {
  8475. info := yaml.MapSlice{}
  8476. if m.Name != "" {
  8477. info = append(info, yaml.MapItem{"name", m.Name})
  8478. }
  8479. if m.Description != "" {
  8480. info = append(info, yaml.MapItem{"description", m.Description})
  8481. }
  8482. if m.ExternalDocs != nil {
  8483. info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()})
  8484. }
  8485. // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:}
  8486. if m.VendorExtension != nil {
  8487. for _, item := range m.VendorExtension {
  8488. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8489. }
  8490. }
  8491. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8492. return info
  8493. }
  8494. // ToRawInfo returns a description of TypeItem suitable for JSON or YAML export.
  8495. func (m *TypeItem) ToRawInfo() interface{} {
  8496. info := yaml.MapSlice{}
  8497. if len(m.Value) != 0 {
  8498. info = append(info, yaml.MapItem{"value", m.Value})
  8499. }
  8500. return info
  8501. }
  8502. // ToRawInfo returns a description of VendorExtension suitable for JSON or YAML export.
  8503. func (m *VendorExtension) ToRawInfo() interface{} {
  8504. info := yaml.MapSlice{}
  8505. if m.AdditionalProperties != nil {
  8506. for _, item := range m.AdditionalProperties {
  8507. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8508. }
  8509. }
  8510. // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:}
  8511. return info
  8512. }
  8513. // ToRawInfo returns a description of Xml suitable for JSON or YAML export.
  8514. func (m *Xml) ToRawInfo() interface{} {
  8515. info := yaml.MapSlice{}
  8516. if m.Name != "" {
  8517. info = append(info, yaml.MapItem{"name", m.Name})
  8518. }
  8519. if m.Namespace != "" {
  8520. info = append(info, yaml.MapItem{"namespace", m.Namespace})
  8521. }
  8522. if m.Prefix != "" {
  8523. info = append(info, yaml.MapItem{"prefix", m.Prefix})
  8524. }
  8525. if m.Attribute != false {
  8526. info = append(info, yaml.MapItem{"attribute", m.Attribute})
  8527. }
  8528. if m.Wrapped != false {
  8529. info = append(info, yaml.MapItem{"wrapped", m.Wrapped})
  8530. }
  8531. if m.VendorExtension != nil {
  8532. for _, item := range m.VendorExtension {
  8533. info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()})
  8534. }
  8535. }
  8536. // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:}
  8537. return info
  8538. }
  8539. var (
  8540. pattern0 = regexp.MustCompile("^x-")
  8541. pattern1 = regexp.MustCompile("^/")
  8542. pattern2 = regexp.MustCompile("^([0-9]{3})$|^(default)$")
  8543. )