@michaelmishin/speclens 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/speclens.iife.js +1 -1
- package/dist/speclens.iife.js.map +1 -1
- package/dist/speclens.js +1 -1
- package/dist/speclens.js.map +1 -1
- package/package.json +1 -1
package/dist/speclens.iife.js
CHANGED
|
@@ -1963,7 +1963,7 @@ const du=2;class uu{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r)
|
|
|
1963
1963
|
position: static;
|
|
1964
1964
|
}
|
|
1965
1965
|
}
|
|
1966
|
-
`],nh([je({type:Object})],oh.prototype,"operation",2),nh([je({type:Array})],oh.prototype,"servers",2),nh([je({type:Array})],oh.prototype,"securitySchemes",2),nh([je({type:Object})],oh.prototype,"authState",2),nh([je({type:String})],oh.prototype,"proxyUrl",2),nh([je({type:Boolean,attribute:"hide-try-it"})],oh.prototype,"hideTryIt",2),nh([je({type:Boolean,attribute:"hide-code-samples"})],oh.prototype,"hideCodeSamples",2),nh([je({type:String})],oh.prototype,"activeOperationId",2),nh([Oe()],oh.prototype,"_expanded",2),oh=nh([_e("sl-operation")],oh);var sh=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,ah=(e,t,r,n)=>{for(var o,s=n>1?void 0:n?ih(t,r):t,i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n?o(t,r,s):o(s))||s);return n&&s&&sh(t,r,s),s};let lh=class extends xe{constructor(){super(...arguments),this.servers=[],this.securitySchemes=[],this.authState={apiKeys:{},bearerTokens:{}},this.proxyUrl="",this._paramValues={},this._bodyValue="",this._selectedServer=0,this._response=null,this._loading=!1,this._error=null,this._showResponseHeaders=!1,this._initialized=!1}willUpdate(){!this._initialized&&this.operation&&(this._initDefaults(),this._initialized=!0)}_initDefaults(){const e={};for(const t of this.operation.parameters)void 0!==t.example&&(e[`${t.in}:${t.name}`]=String(t.example));if(this._paramValues=e,this.operation.requestBody){const e=this.operation.requestBody.content[0];if(null==e?void 0:e.schema)try{const t=su(e.schema);this._bodyValue=JSON.stringify(t,null,2)}catch{this._bodyValue="{}"}}}_buildUrl(){const e=this.operation.servers.length>0?this.operation.servers:this.servers,t=e[this._selectedServer]??e[0];if(!t)return this.operation.path;let r=t.url;for(const[s,i]of Object.entries(t.variables))r=r.replace(`{${s}}`,i.default);let n=this.operation.path;for(const s of this.operation.parameters.filter(e=>"path"===e.in)){const e=this._paramValues[`path:${s.name}`]??"";n=n.replace(`{${s.name}}`,encodeURIComponent(e))}const o=this.operation.parameters.filter(e=>"query"===e.in).map(e=>{const t=this._paramValues[`query:${e.name}`];return t?`${encodeURIComponent(e.name)}=${encodeURIComponent(t)}`:null}).filter(Boolean);return`${r}${n}${o.length>0?`?${o.join("&")}`:""}`}_buildHeaders(){const e={};for(const t of this.operation.parameters.filter(e=>"header"===e.in)){const r=this._paramValues[`header:${t.name}`];r&&(e[t.name]=r)}for(const t of this.operation.security)for(const r of Object.keys(t)){const t=this.securitySchemes.find(e=>e.key===r);if(t){if("apiKey"===t.type&&"header"===t.in&&t.name){const n=this.authState.apiKeys[r];n&&(e[t.name]=n)}if("http"===t.type){const n=this.authState.bearerTokens[r];n&&("bearer"===t.scheme?e.Authorization=`Bearer ${n}`:"basic"===t.scheme&&(e.Authorization=`Basic ${btoa(n)}`))}}}if(this.operation.requestBody){const t=this.operation.requestBody.content[0];t&&(e["Content-Type"]=t.mediaType)}return e}async _send(){this._loading=!0,this._error=null,this._response=null;const e=this._buildUrl(),t=this._buildHeaders(),r=this.operation.requestBody&&["post","put","patch"].includes(this.operation.method),n=this.proxyUrl?`${this.proxyUrl}${encodeURIComponent(e)}`:e,o=performance.now();try{const e=await fetch(n,{method:this.operation.method.toUpperCase(),headers:t,body:r?this._bodyValue:void 0}),s=Math.round(performance.now()-o),i=await e.text(),a={};e.headers.forEach((e,t)=>{a[t]=e}),this._response={status:e.status,statusText:e.statusText,headers:a,body:i,time:s}}catch(s){const e=s instanceof Error?s.message:String(s);this._error=e}finally{this._loading=!1}}_getStatusClass(e){return e<300?"status-2xx":e<400?"status-3xx":e<500?"status-4xx":"status-5xx"}_formatBody(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}render(){if(!this.operation)return ne``;const e=this.operation.parameters.filter(e=>"path"===e.in),t=this.operation.parameters.filter(e=>"query"===e.in),r=this.operation.parameters.filter(e=>"header"===e.in),n=this.operation.servers.length>0?this.operation.servers:this.servers;return ne`
|
|
1966
|
+
`],nh([je({type:Object})],oh.prototype,"operation",2),nh([je({type:Array})],oh.prototype,"servers",2),nh([je({type:Array})],oh.prototype,"securitySchemes",2),nh([je({type:Object})],oh.prototype,"authState",2),nh([je({type:String})],oh.prototype,"proxyUrl",2),nh([je({type:Boolean,attribute:"hide-try-it"})],oh.prototype,"hideTryIt",2),nh([je({type:Boolean,attribute:"hide-code-samples"})],oh.prototype,"hideCodeSamples",2),nh([je({type:String})],oh.prototype,"activeOperationId",2),nh([Oe()],oh.prototype,"_expanded",2),oh=nh([_e("sl-operation")],oh);var sh=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,ah=(e,t,r,n)=>{for(var o,s=n>1?void 0:n?ih(t,r):t,i=e.length-1;i>=0;i--)(o=e[i])&&(s=(n?o(t,r,s):o(s))||s);return n&&s&&sh(t,r,s),s};let lh=class extends xe{constructor(){super(...arguments),this.servers=[],this.securitySchemes=[],this.authState={apiKeys:{},bearerTokens:{}},this.proxyUrl="",this._paramValues={},this._bodyValue="",this._selectedServer=0,this._response=null,this._loading=!1,this._error=null,this._showResponseHeaders=!1,this._initialized=!1}willUpdate(){!this._initialized&&this.operation&&(this._initDefaults(),this._initialized=!0)}_initDefaults(){const e={};for(const t of this.operation.parameters)void 0!==t.example&&(e[`${t.in}:${t.name}`]=String(t.example));if(this._paramValues=e,this.operation.requestBody){const e=this.operation.requestBody.content[0];if(null==e?void 0:e.schema)try{const t=su(e.schema);this._bodyValue=JSON.stringify(t,null,2)}catch{this._bodyValue="{}"}}}_buildUrl(){const e=this.operation.servers.length>0?this.operation.servers:this.servers,t=e[this._selectedServer]??e[0];if(!t)return this.operation.path;let r=t.url.replace(/\/+$/,"");for(const[s,i]of Object.entries(t.variables))r=r.replace(`{${s}}`,i.default);let n=this.operation.path;for(const s of this.operation.parameters.filter(e=>"path"===e.in)){const e=this._paramValues[`path:${s.name}`]??"";n=n.replace(`{${s.name}}`,encodeURIComponent(e))}const o=this.operation.parameters.filter(e=>"query"===e.in).map(e=>{const t=this._paramValues[`query:${e.name}`];return t?`${encodeURIComponent(e.name)}=${encodeURIComponent(t)}`:null}).filter(Boolean);return`${r}${n}${o.length>0?`?${o.join("&")}`:""}`}_buildHeaders(){const e={};for(const t of this.operation.parameters.filter(e=>"header"===e.in)){const r=this._paramValues[`header:${t.name}`];r&&(e[t.name]=r)}for(const t of this.operation.security)for(const r of Object.keys(t)){const t=this.securitySchemes.find(e=>e.key===r);if(t){if("apiKey"===t.type&&"header"===t.in&&t.name){const n=this.authState.apiKeys[r];n&&(e[t.name]=n)}if("http"===t.type){const n=this.authState.bearerTokens[r];n&&("bearer"===t.scheme?e.Authorization=`Bearer ${n}`:"basic"===t.scheme&&(e.Authorization=`Basic ${btoa(n)}`))}}}if(this.operation.requestBody){const t=this.operation.requestBody.content[0];t&&(e["Content-Type"]=t.mediaType)}return e}async _send(){this._loading=!0,this._error=null,this._response=null;const e=this._buildUrl(),t=this._buildHeaders(),r=this.operation.requestBody&&["post","put","patch"].includes(this.operation.method),n=this.proxyUrl?`${this.proxyUrl}${encodeURIComponent(e)}`:e,o=performance.now();try{const e=await fetch(n,{method:this.operation.method.toUpperCase(),headers:t,body:r?this._bodyValue:void 0}),s=Math.round(performance.now()-o),i=await e.text(),a={};e.headers.forEach((e,t)=>{a[t]=e}),this._response={status:e.status,statusText:e.statusText,headers:a,body:i,time:s}}catch(s){const e=s instanceof Error?s.message:String(s);this._error=e}finally{this._loading=!1}}_getStatusClass(e){return e<300?"status-2xx":e<400?"status-3xx":e<500?"status-4xx":"status-5xx"}_formatBody(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}render(){if(!this.operation)return ne``;const e=this.operation.parameters.filter(e=>"path"===e.in),t=this.operation.parameters.filter(e=>"query"===e.in),r=this.operation.parameters.filter(e=>"header"===e.in),n=this.operation.servers.length>0?this.operation.servers:this.servers;return ne`
|
|
1967
1967
|
<div class="try-it">
|
|
1968
1968
|
${e.length>0?ne`
|
|
1969
1969
|
<div class="form-section">
|