Skip to content

Commit

Permalink
Add WASM module to convert schema.json to OpenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
swallez committed Oct 13, 2023
1 parent ada969a commit 1a1b5b4
Show file tree
Hide file tree
Showing 21 changed files with 4,027 additions and 2,798 deletions.
11 changes: 11 additions & 0 deletions compiler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"format:fix": "prettier --config .prettierrc.json --write ../specification/",
"generate-schema": "ts-node src/index.ts",
"transform-expand-generics": "ts-node src/transform/expand-generics.ts",
"transform-to-openapi": "ts-node src/transform/schema-to-openapi.ts",
"filter-by-availability": "ts-node src/transform/filter-by-availability.ts",
"dump-routes": "ts-node src/dump/extract-routes.ts",
"compile:specification": "tsc --project ../specification/tsconfig.json --noEmit",
Expand All @@ -36,6 +37,7 @@
"fastest-levenshtein": "^1.0.12",
"ora": "^5.4.1",
"safe-stable-stringify": "^2.3.1",
"schema-wasm-lib": "file:../openapi-converter/schema-wasm-lib/pkg",
"semver": "^7.5.2",
"ts-morph": "^13.0.3",
"zx": "^4.3.0"
Expand Down
21 changes: 21 additions & 0 deletions compiler/src/transform/schema-to-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {convert_schema_to_openapi} from 'schema-wasm-lib';
import {argv} from "zx";
import {join} from "path";
import {readFileSync, writeFileSync} from "fs";


const inputPath = argv.input ?? join(__dirname, '..', '..', '..', 'output', 'schema', 'schema.json')
const outputPath = argv.output ?? join(__dirname, '..', '..', '..', 'output', 'openapi', 'elasticsearch-serverless-openapi.json')

const inputText = readFileSync(
inputPath,
{ encoding: 'utf8' }
);

const output = convert_schema_to_openapi(inputText, "serverless");

writeFileSync(
outputPath,
output,
'utf8'
)
194 changes: 178 additions & 16 deletions openapi-converter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion openapi-converter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
[workspace]
resolver = "2"
members = [
"clients_schema",
"openapi_to_clients_schema",
"clients_schema_to_openapi"
"clients_schema_to_openapi",
"schema-wasm-lib",
]

[profile.release]
lto = true
# Tell `rustc` to optimize for small code size.
opt-level = "s"
Loading

0 comments on commit 1a1b5b4

Please sign in to comment.