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