const fs = require('fs')
const path = require('path')
const schemasPath = path.join(__dirname, 'dist')

// Assemble compiled schema files into an object
// keys are shorthand names like `dotcom` and `2.20`
// values are full OpenAPI schema objects
const schemas = {}
fs.readdirSync(schemasPath)
  .filter(filename => filename.endsWith('.json'))
  .map(filename => {
    const key = filename.replace('.json', '')
    const value = require(path.join(schemasPath, filename))
    schemas[key] = value
  })

module.exports = schemas
