MCPcopy
hub / github.com/rapi-doc/RapiDoc / attributeChangedCallback

Method attributeChangedCallback

src/rapidoc-mini.js:210–279  ·  view source on GitHub ↗
(name, oldVal, newVal)

Source from the content-addressed store, hash-verified

208 }
209
210 attributeChangedCallback(name, oldVal, newVal) {
211 if (name === 'spec-url') {
212 if (oldVal !== newVal) {
213 // put it at the end of event-loop to load all the attributes
214 window.setTimeout(async () => {
215 await this.loadSpec(newVal);
216 }, 0);
217 }
218 }
219 if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
220 if (oldVal !== newVal) {
221 window.setTimeout(async () => {
222 await this.loadSpec(this.specUrl);
223 }, 0);
224 }
225 }
226 if (name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value') {
227 let updateSelectedApiKey = false;
228 let apiKeyName = '';
229 let apiKeyLocation = '';
230 let apiKeyValue = '';
231
232 if (name === 'api-key-name') {
233 if (this.getAttribute('api-key-location') && this.getAttribute('api-key-value')) {
234 apiKeyName = newVal;
235 apiKeyLocation = this.getAttribute('api-key-location');
236 apiKeyValue = this.getAttribute('api-key-value');
237 updateSelectedApiKey = true;
238 }
239 } else if (name === 'api-key-location') {
240 if (this.getAttribute('api-key-name') && this.getAttribute('api-key-value')) {
241 apiKeyLocation = newVal;
242 apiKeyName = this.getAttribute('api-key-name');
243 apiKeyValue = this.getAttribute('api-key-value');
244 updateSelectedApiKey = true;
245 }
246 } else if (name === 'api-key-value') {
247 if (this.getAttribute('api-key-name') && this.getAttribute('api-key-location')) {
248 apiKeyValue = newVal;
249 apiKeyLocation = this.getAttribute('api-key-location');
250 apiKeyName = this.getAttribute('api-key-name');
251 updateSelectedApiKey = true;
252 }
253 }
254
255 if (updateSelectedApiKey) {
256 if (this.resolvedSpec) {
257 const rapiDocApiKey = this.resolvedSpec.securitySchemes.find((v) => v.securitySchemeId === rapidocApiKey);
258 if (!rapiDocApiKey) {
259 this.resolvedSpec.securitySchemes.push({
260 apiKeyId: rapidocApiKey,
261 description: 'api-key provided in rapidoc element attributes',
262 type: 'apiKey',
263 name: apiKeyName,
264 in: apiKeyLocation,
265 value: apiKeyValue,
266 finalKeyValue: apiKeyValue,
267 });

Callers

nothing calls this directly

Calls 4

loadSpecMethod · 0.95
findMethod · 0.45
pushMethod · 0.45
requestUpdateMethod · 0.45

Tested by

no test coverage detected