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