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