Skip to content

Commit

Permalink
OD-15939 Moved api-docs to separate project
Browse files Browse the repository at this point in the history
  • Loading branch information
yuryyas committed Apr 27, 2021
1 parent 4252e71 commit 0abd17b
Show file tree
Hide file tree
Showing 10 changed files with 4,596 additions and 32 deletions.
40 changes: 40 additions & 0 deletions api-doc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apply plugin: 'com.github.node-gradle.node'

node {
version = '12.19.0'
yarnVersion = '1.22.10'
download = System.properties['os.name'] != "FreeBSD" // FreeBSD has no binaries this plugin can install
workDir = file("${project.buildDir}/nodejs")
}

yarn.outputs.cacheIf { true }

clean {
delete "${projectDir}/node_modules"
}

task apiDoc(type: YarnTask, dependsOn: [':server-api:apiDocs_mergeSwagger', 'yarn']) {
group = "documentation"
args = ['build',
'--env',
'schema',
tasks.getByPath(':server-api:apiDocs_mergeSwagger').outputs.files.first().toString()]
}

build.dependsOn(apiDoc)

task packageApiDoc (type: Zip, dependsOn: apiDoc) {
group = "documentation"
from file("${buildDir}/api-docs")
archiveClassifier = 'documentation'
}

publishing {
publications {
docs(MavenPublication) {
artifact(packageApiDoc) {
artifactId "apiDoc"
}
}
}
}
32 changes: 32 additions & 0 deletions api-doc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"scripts": {
"build": "webpack --progress --node-env production --config webpack.api.doc.config.js",
"start": "webpack serve --history-api-fallback --progress --open --node-env development --config webpack.api.doc.config.js --env schema ../server-api/build/swagger-merged/swagger.yaml "
},
"devDependencies": {
"buffer": "^6.0.3",
"builtin-status-codes": "^3.0.0",
"compression-webpack-plugin": "^7.1.2",
"core-js": "^3.11.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.1",
"mini-css-extract-plugin": "^1.5.0",
"os": "^0.1.1",
"path": "^0.12.7",
"terser-webpack-plugin": "^5.1.1",
"to-arraybuffer": "^1.0.1",
"ts-loader": "^9.1.1",
"typescript": "^4.2.4",
"webpack": "^5.36.0",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2",
"xtend": "^4.0.2"
},
"dependencies": {
"mobx": "^6.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"redoc": "^2.0.0-rc.53",
"styled-components": "^5.2.3"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { RedocStandalone } from 'redoc';

const start = () => {
ReactDOM.render(
<RedocStandalone specUrl="swagger.yaml" />,
<RedocStandalone
specUrl="swagger.yaml"
options={{
noAutoAuth: true,
nativeScrollbars: true
}}
/>,
document.getElementById("docs-root")
);
};
Expand Down
31 changes: 31 additions & 0 deletions api-doc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"rootDirs": [
"src"
],
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"strictNullChecks": false,
"module": "esnext",
"skipLibCheck": true,
"target": "es2015",
"jsx": "react",
"lib": [
"dom",
"esnext",
"es5",
"es6",
"es7"
]
},
"compileOnSave": false,
"exclude": [
"./node_modules*",
"./build*"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CompressionPlugin = require("compression-webpack-plugin");

module.exports = () => {
const swaggerPath = process.argv.indexOf("--schema") !== -1 && process.argv[process.argv.indexOf("--schema") + 1];
const swaggerPath = process.argv.indexOf("schema") !== -1 && process.argv[process.argv.indexOf("schema") + 1];

if (!swaggerPath) {
throw new Error("Swagger schema file is required !");
Expand All @@ -23,12 +23,12 @@ module.exports = () => {
return {
entry: [
swaggerPath,
"./src/api-docs/apiDocs.tsx"
"./src/apiDocs.tsx"
],
output: {
path: path.resolve(__dirname, "build/api-docs"),
},
mode: "development",
mode: process.env.NODE_ENV,
resolve: {
modules: [
"node_modules"
Expand All @@ -48,7 +48,7 @@ module.exports = () => {
}
],
include: [
path.resolve(__dirname, "src/api-docs/apiDocs.tsx")
path.resolve(__dirname, "src/apiDocs.tsx")
],
exclude: [
path.resolve(__dirname, "node_modules")
Expand All @@ -66,20 +66,26 @@ module.exports = () => {
]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: "buffer"
}),
new HtmlWebpackPlugin({
template: "src/api-docs/api-doc-template.html",
template: "src/api-doc-template.html",
}),
new webpack.WatchIgnorePlugin({
paths: [
/\.js$/,
path.resolve(__dirname, "node_modules"),
],
}),
new webpack.WatchIgnorePlugin([
/\.js$/,
path.resolve(__dirname, "node_modules")
]),
new MiniCssExtractPlugin({ filename: '[name].css' }),
new webpack.SourceMapDevToolPlugin({
filename: "[file].map",
exclude: [/vendor/, /images/, /hot-update/]
}),
new CompressionPlugin({
filename: `[path].gz`,
filename: `[file].gz`,
algorithm: "gzip",
test: /\.(js|html|css)$/,
threshold: 10240,
Expand All @@ -89,8 +95,7 @@ module.exports = () => {
optimization: {
minimizer: [
new TerserPlugin({
parallel: 4,
sourceMap: true
parallel: 4
})
]
},
Expand All @@ -99,9 +104,6 @@ module.exports = () => {
hot: true,
port: 8100
},
devtool: false,
node: {
fs: "empty"
}
devtool: false
};
};
Loading

0 comments on commit 0abd17b

Please sign in to comment.