Skip to content

Commit

Permalink
[#446][Part 2] Add OpenAPI to support creating API documentation with…
Browse files Browse the repository at this point in the history
… OpenAPI (#465)

* [#446] Add endpoint and template html

* [#446] Update route

* [#446] Rename stoplight to openapi

* [#446] Remove redundant route

* [#446] Update tests location
  • Loading branch information
sanG-github authored Sep 29, 2023
1 parent f918404 commit fe2f59a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .template/addons/openapi/public/openapi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>API documentation</title>
<!-- Embed Elements via Web Component -->
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
</head>

<body>
<elements-api apiDescriptionUrl="/openapi.yml" router="hash" layout="sidebar" />
</body>
</html>
5 changes: 5 additions & 0 deletions .template/addons/openapi/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
apply '.gitignore.rb'
apply 'package.json.rb'
copy_file '.spectral.yml'
copy_file 'public/openapi.html'

after_bundle do
run 'yarn build:docs'
end
4 changes: 4 additions & 0 deletions .template/spec/addons/base/openapi/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
expect(file('.spectral.yml')).to exist
end

it 'creates the HTML template file' do
expect(file('public/openapi.html')).to exist
end

it 'creates Github actions workflows' do
expect(file('.github/workflows/lint_docs.yml')).to exist
end
Expand Down

0 comments on commit fe2f59a

Please sign in to comment.