-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into restrictions-remove-ff
- Loading branch information
Showing
62 changed files
with
4,439 additions
and
1,080 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
|
||
[*.{js,jsx,ts,tsx,mjs,yaml,yml}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.edge] | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
output/ | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
### Node Patch ### | ||
# Serverless Webpack directories | ||
.webpack/ | ||
|
||
# Optional stylelint cache | ||
|
||
# SvelteKit build / generate output | ||
.svelte-kit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"arrowParens": "always", | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenAPI Spec to Markdown Generator | ||
|
||
This is a tool for generating Markdown documentation from an OpenAPI spec. | ||
|
||
## Setup | ||
|
||
1. Make sure you have [Node.js](https://nodejs.org/) v20 (or later) and `npm` installed | ||
2. In `_generator` run `npm install` | ||
|
||
## Usage | ||
|
||
Without providing any arguments, the generator will pick up the configuration from [config.yaml](config.yaml) file. | ||
|
||
```shell | ||
# cd _generator | ||
node index.js | ||
``` | ||
|
||
Alternatively, you can override individual or all configuration arguments via CLI: | ||
|
||
```shell | ||
node index.js --source https://api.mews.com/swagger/connector/swagger.yaml --output some/alternative/output/path --tags bills --tags accounts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { getSchemaId } from './utils.js'; | ||
|
||
/** | ||
* @typedef { import('oas/operation').Operation } Operation | ||
* @typedef { import('openapi-types').OpenAPIV3.SchemaObject } SchemaObject | ||
* @typedef { import('openapi-types').OpenAPIV3.ResponseObject } ResponseObject | ||
* @typedef { import('openapi-types').OpenAPIV3.Document } OASDocument | ||
* @typedef { import('oas').default } Oas | ||
* @typedef { import('./types.js').TemplateSchema } TemplateSchema | ||
* @typedef { import('./types.js').TemplateProperty } TemplateProperty | ||
* @typedef { import('./types.js').TemplateEnumEntry } TemplateEnumEntry | ||
* @typedef { import('./types-resolver.js').SchemasAccumulator } SchemasAccumulator | ||
*/ | ||
|
||
/** | ||
* Traverse schema, collect all nested schemas | ||
* @param {SchemaObject} schema | ||
* @param {string[]} path | ||
* @param {SchemasAccumulator} accumulator | ||
* @returns {SchemasAccumulator} | ||
*/ | ||
export function collectSchemas(schema, path, accumulator) { | ||
const schemaId = getSchemaId(schema); | ||
const nestedPath = [...path]; | ||
schema['x-schema-paths'] ??= []; | ||
schema['x-schema-paths'].push(path); | ||
|
||
if (schemaId) { | ||
accumulator.add(schemaId, schema); | ||
nestedPath.push(schemaId); | ||
} | ||
|
||
if (schema.type === 'object' || schema.properties?.discriminator) { | ||
for (const key in schema.properties) { | ||
collectSchemas(schema.properties[key], [...nestedPath, key], accumulator); | ||
} | ||
} | ||
if (schema.type === 'array') { | ||
collectSchemas(schema.items, nestedPath, accumulator); | ||
} | ||
const composedSchemas = schema.anyOf || schema.oneOf || schema.allOf || []; | ||
for (const item of composedSchemas) { | ||
collectSchemas(item, nestedPath, accumulator); | ||
} | ||
return accumulator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { parseArgs } from 'node:util'; | ||
import { loadYaml } from './utils.js'; | ||
|
||
const CONFIG_PATH = './config.yaml'; | ||
|
||
function loadArgs() { | ||
const parsedArgs = parseArgs({ | ||
options: { | ||
tags: { | ||
type: 'string', | ||
alias: 't', | ||
multiple: true, | ||
default: [], | ||
}, | ||
source: { | ||
type: 'string', | ||
alias: 's', | ||
}, | ||
output: { | ||
type: 'string', | ||
alias: 'o', | ||
}, | ||
}, | ||
}); | ||
const tags = | ||
parsedArgs.values.tags.length > 0 ? parsedArgs.values.tags : undefined; | ||
return { | ||
source: parsedArgs.values.source || undefined, | ||
output: parsedArgs.values.output || undefined, | ||
tags, | ||
}; | ||
} | ||
|
||
export function loadConfig() { | ||
const args = loadArgs(); | ||
const yamlConfig = loadYaml(CONFIG_PATH); | ||
const config = { | ||
oasPath: args.source || yamlConfig.source, | ||
outputPath: args.output || yamlConfig.output, | ||
tags: args.tags || yamlConfig.tags || [], | ||
}; | ||
if (!config.oasPath && !config.outputPath) { | ||
console.error( | ||
'Usage: node index.js --source <url-or-path-to-openapi> --output <output-folder> [--tags tag1 [--tags "some tag2"]]' | ||
); | ||
throw new Error('Missing required arguments'); | ||
} | ||
// TODO: This check can be removed after initial migration; if no tags are provided, generator will pick up all tags by default | ||
if (config.tags.length === 0) { | ||
throw new Error('No tags specified'); | ||
} | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
source: https://api.mews.com/swagger/connector/swagger.yaml | ||
output: ../operations | ||
tags: | ||
# - accountingcategories | ||
# - accountingitems | ||
- accountnotes | ||
# - accounts | ||
# - addresses | ||
# - agecategories | ||
# - availabilityadjustments | ||
# - availabilityblocks | ||
# - bills | ||
# - businesssegments | ||
# - cancellationpolicies | ||
# - cashiers | ||
# - cashiertransactions | ||
# - commands | ||
# - companies | ||
# - companionships | ||
# - companycontracts | ||
# - configuration | ||
# - counters | ||
- countries | ||
# - creditcards | ||
- currencies | ||
# - customers | ||
# - departments | ||
- devices | ||
# - enterprises | ||
- exchangerates | ||
# - exports | ||
- images | ||
# - languages | ||
# - loyaltymemberships | ||
# - loyaltyprograms | ||
# - loyaltytiers | ||
# - messages | ||
# - messagethreads | ||
- orderitems | ||
# - orders | ||
# - outletbills | ||
# - outletitems | ||
# - outlets | ||
# - paymentrequests | ||
# - payments | ||
# - preauthorizations | ||
# - productcategories | ||
# - products | ||
# - productserviceorders | ||
# - rategroups | ||
# - rates | ||
# - reservationgroups | ||
# - reservations | ||
# - resourceaccesstokens | ||
# - resourceblocks | ||
# - resourcecategories | ||
# - resourcefeatures | ||
# - resources | ||
# - restrictions | ||
# - routingrules | ||
# - rules | ||
# - serviceordernotes | ||
- services | ||
# - sourceassignments | ||
# - sources | ||
# - tasks | ||
# - taxations | ||
# - taxenvironments | ||
# - vouchercodes | ||
# - vouchers |
Oops, something went wrong.