Skip to content

Commit

Permalink
Merge pull request #14 from qazsato/add_description_option
Browse files Browse the repository at this point in the history
Add description option
  • Loading branch information
qazsato authored Nov 25, 2024
2 parents 28058ce + e0513d4 commit 4a4c2f3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ npx openapi-generate-html -i openapi.json --theme=dark
| --ui | "stoplight" | Choose UI (stoplight / swagger / redoc) |
| --theme | "light" | Choose Theme (light / dark) |
| --title | "OpenAPI Docs" | Title of the HTML page |
| --description | | Description of the HTML page |

## UI Pattern

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
},
"keywords": [
"OpenAPI",
"Stoplight"
"Stoplight",
"Swagger",
"Redoc"
],
"author": "qazsato <[email protected]>",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions resources/redoc/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title><%= title %></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<%= description %>">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<style><%- cssContent %></style>
Expand Down
1 change: 1 addition & 0 deletions resources/stoplight/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title><%= title %></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<%= description %>">
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<style><%- cssContent %></style>
Expand Down
1 change: 1 addition & 0 deletions resources/swagger/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title><%= title %></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<%= description %>">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
<style><%- cssContent %></style>
<script>window.apiDocs = <%- apiDocs %></script>
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function getCliOptions() {
)
.option('--ui <ui>', `Choose UI (${UI.join(', ')})`, validateCommandUi)
.option('--title <title>', 'Title of the HTML page', 'OpenAPI Docs')
.option('--description <description>', 'Description of the HTML page', '')
.option(
'--theme <theme>',
'Theme of the HTML page. Choose from light or dark.',
Expand Down Expand Up @@ -92,8 +93,6 @@ async function askQuestions(options) {

async function renderOpenApiHtml(result) {
const ui = result.ui
const theme = result.theme
const title = result.title

const template = fs.readFileSync(
path.resolve(__dirname, `../resources/${ui}/template.ejs`),
Expand Down Expand Up @@ -132,8 +131,9 @@ async function renderOpenApiHtml(result) {
const apiDocs = await $RefParser.bundle(rawApiDocs)

return ejs.render(template, {
theme,
title,
theme: result.theme,
title: result.title,
description: result.description,
jsContent,
cssContent,
apiDocs: JSON.stringify(apiDocs),
Expand Down

0 comments on commit 4a4c2f3

Please sign in to comment.