import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{joinWithSeparator as M}from"../services/index.js";import{extractExtensions as V,getValueFromMdParsedExtension as E,mapValues as I,removePercentChart as L}from"../utils/index.js";import{getSchema as T}from"./schema.js";import{getExamples as _}from"./example.js";const F={path:{style:"simple",explode:!1},query:{style:"form",explode:!0},header:{style:"simple",explode:!1},cookie:{style:"form",explode:!0},querystring:{style:"form",explode:!0}};function N(l,i,p,a,d,x,g=p){const{resolved:e}=l.deref(i),P=i.kind||"field",f=i.name||e.name,n=e.in,v=!!e.required;let r=e.schema,u,s="",c;if(!r&&e.in&&e.content){s=Object.keys(e.content)[0];const t=e.content[s];r=t&&t?.example?{...l.deref(t.schema,x,!0).resolved,example:e.example||t.example}:t.schema}const h=M(d.parentFieldFullPath,L(f||"")),o=T({parser:l,schemaOrRef:r||{},pointer:p,options:a,baseRefsStack:x,absolutePointer:i.$ref||e.schema?.absolutePointer||g,deps:{...d,parentFieldFullPath:h,in:n}}),w=e.description===void 0?E(o,"description")||"":E(e,"description"),R=e.example||o.example,y=e.examples||e.content?.[s]?.examples,S=y?I(y,(t,C)=>_({parser:l,infoOrRef:t,mime:C,encoding:e.encoding})):void 0;s?u=s:e.style?c=e.style:n&&(c=F[n]?.style??"form");const A=e.explode===void 0&&n?F[n]?.explode??!0:!!e.explode,b=e.deprecated===void 0?o.deprecated:e.deprecated,k=a.showExtensions?V(e,a.showExtensions):void 0,q=o?.const||e?.const||"";return{deps:d||{},schema:o,name:f,required:v,description:w,example:R,examples:S,deprecated:b,in:n,kind:P,extensions:k,explode:A,style:c,const:q,serializationMime:u,fieldFullPath:h,...e.allowReserved&&{allowReserved:e.allowReserved},[m]:e[m]||o[m]}}export{N as getField};
