"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getField=void 0;const utils_1=require("../utils"),schema_1=require("./schema"),example_1=require("./example"),DEFAULT_SERIALIZATION={path:{style:"simple",explode:!1},query:{style:"form",explode:!0},header:{style:"simple",explode:!1},cookie:{style:"form",explode:!0}};function getField(e,l,i,t,s,o,n=i){var d,a,r,p,c,m,u;const{resolved:x}=e.deref(l),v=l.kind||"field",h=l.name||x.name,F=x.in,f=!!x.required;let g,_,E=x.schema,y="";if(!E&&x.in&&x.content){y=Object.keys(x.content)[0];const l=x.content[y];E=l&&(null==l?void 0:l.example)?Object.assign(Object.assign({},e.deref(l.schema,o,!0).resolved),{example:x.example||l.example}):l.schema}const O=(null==s?void 0:s.parentFieldFullPath)?s.parentFieldFullPath+"/"+h:h,b=(0,schema_1.getSchema)({parser:e,schemaOrRef:E||{},pointer:i,options:t,baseRefsStack:o,absolutePointer:l.$ref||(null===(d=x.schema)||void 0===d?void 0:d.absolutePointer)||n,deps:Object.assign(Object.assign({},s),{parentFieldFullPath:O,in:F})}),A=void 0===x.description?(0,utils_1.getValueFromMdParsedExtension)(b,"description")||"":(0,utils_1.getValueFromMdParsedExtension)(x,"description"),I=x.example||b.example,P=x.examples||(null===(r=null===(a=x.content)||void 0===a?void 0:a[y])||void 0===r?void 0:r.examples),j=P?(0,utils_1.mapValues)(P,((l,i)=>(0,example_1.getExamples)({parser:e,infoOrRef:l,mime:i,encoding:x.encoding}))):void 0;y?g=y:x.style?_=x.style:F&&(_=null!==(c=null===(p=DEFAULT_SERIALIZATION[F])||void 0===p?void 0:p.style)&&void 0!==c?c:"form");const q=void 0===x.explode&&F?null===(u=null===(m=DEFAULT_SERIALIZATION[F])||void 0===m?void 0:m.explode)||void 0===u||u:!!x.explode;return{deps:s||{},schema:b,name:h,required:f,description:A,example:I,examples:j,deprecated:void 0===x.deprecated?b.deprecated:x.deprecated,in:F,kind:v,extensions:t.showExtensions?(0,utils_1.extractExtensions)(x,t.showExtensions):void 0,explode:q,style:_,const:(null==b?void 0:b.const)||(null==x?void 0:x.const)||"",serializationMime:g,fieldFullPath:O}}exports.getField=getField;
//# sourceMappingURL=field.js.map