MCPcopy Index your code
hub / github.com/github/docs / constructor

Method constructor

src/rest/scripts/utils/operation.js:19–54  ·  view source on GitHub ↗
(verb, requestPath, operation, globalServers)

Source from the content-addressed store, hash-verified

17export default class Operation {
18 #operation
19 constructor(verb, requestPath, operation, globalServers) {
20 this.#operation = operation
21 // The global server object sets metadata including the base url for
22 // all operations in a version. Individual operations can override
23 // the global server url at the operation level.
24 this.serverUrl = operation.servers ? operation.servers[0].url : globalServers[0].url
25
26 const serverVariables = operation.servers
27 ? operation.servers[0].variables
28 : globalServers[0].variables
29 if (serverVariables) {
30 const templateVariables = {}
31 Object.keys(serverVariables).forEach(
32 (key) => (templateVariables[key] = serverVariables[key].default)
33 )
34 this.serverUrl = parseTemplate(this.serverUrl).expand(templateVariables)
35 }
36
37 this.serverUrl = this.serverUrl.replace('http:', 'http(s):')
38
39 // Attach some global properties to the operation object to use
40 // during processing
41 this.#operation.serverUrl = this.serverUrl
42 this.#operation.requestPath = requestPath
43 this.#operation.verb = verb
44
45 this.verb = verb
46 this.requestPath = requestPath
47 this.title = operation.summary
48 this.setCategories()
49 this.parameters = operation.parameters || []
50 this.bodyParameters = []
51 this.enabledForGitHubApps = operation['x-github'].enabledForGitHubApps
52 this.codeExamples = getCodeSamples(this.#operation)
53 return this
54 }
55
56 setCategories() {
57 const operationId = this.#operation.operationId

Callers

nothing calls this directly

Calls 2

setCategoriesMethod · 0.95
getCodeSamplesFunction · 0.85

Tested by

no test coverage detected