Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

get-operations.js 666 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  1. const Operation = require('./operation')
  2. // The module accepts a JSON schema object as input
  3. // and returns an array of its operation objects with their
  4. // HTTP verb and requestPath attached as properties
  5. module.exports = async function getOperations (schema) {
  6. const operations = []
  7. for (const [requestPath, operationsAtPath] of Object.entries(schema.paths)) {
  8. for (const [verb, props] of Object.entries(operationsAtPath)) {
  9. const serverUrl = schema.servers[0].url
  10. .replace('{protocol}', 'http(s)')
  11. const operation = new Operation(verb, requestPath, props, serverUrl)
  12. operations.push(operation)
  13. }
  14. }
  15. return operations
  16. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...