Skip to content

Instantly share code, notes, and snippets.

@EmilyRosina
Last active October 22, 2018 19:02
Show Gist options
  • Save EmilyRosina/f44dbe17a2b625bcb5c3391061aabf0f to your computer and use it in GitHub Desktop.
Save EmilyRosina/f44dbe17a2b625bcb5c3391061aabf0f to your computer and use it in GitHub Desktop.
Get all endpoints from swagger
const allEndpoints = document.querySelectorAll('.nostyle span')
let endpoints = {}

allEndpoints.forEach(endpoint => {
  if (endpoint.textContent.startsWith('/')) {
    const endpointName = endpoint.textContent.substring(1)
    const params = endpointName.split('/')
    const parent = params[0]
    const restOfName = endpointName.replace(parent, '')
    if (!endpoints[parent]) endpoints[parent] = {}
    endpoints[parent][restOfName.substring(1)] = endpoint.textContent
  }
})

endpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment