Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render html from openapi spec generated by typespec #707

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
770041d
move tsp to resources
munishchouhan Oct 21, 2024
a64fa69
minor change
munishchouhan Oct 21, 2024
618b366
added Dockerfile and build_and_push.sh
munishchouhan Oct 23, 2024
c27a455
added version and typo
munishchouhan Oct 23, 2024
d185114
reverted typespec.yml
munishchouhan Oct 23, 2024
8fcc72d
reverted build.gradle
munishchouhan Oct 23, 2024
5213ec8
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Oct 23, 2024
a79474b
added tag-and-push-docs.sh
munishchouhan Oct 28, 2024
0d4658b
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Oct 28, 2024
cb3620f
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Nov 6, 2024
aa0c234
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Nov 18, 2024
a237891
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Nov 21, 2024
fc4dc50
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Jan 15, 2025
9600f41
change repo
munishchouhan Jan 15, 2025
532303c
added swagger ui
munishchouhan Jan 15, 2025
c1dd3dc
added doc release job
munishchouhan Jan 15, 2025
ff8b60d
removed doc release job from build.yml [ci skip]
munishchouhan Jan 15, 2025
d23bf80
[release-docs] version 1.16.7
munishchouhan Jan 15, 2025
879d24b
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Jan 15, 2025
927c4ad
[release] version 1.16.7
munishchouhan Jan 15, 2025
c014721
Revert "release version 1.16.7"
munishchouhan Jan 15, 2025
dcdb065
added open-api.yml
munishchouhan Jan 15, 2025
c338c3d
corrected repo details
munishchouhan Jan 15, 2025
1aa35c2
corrected repo details
munishchouhan Jan 15, 2025
7e61018
added push in typesepc.yml
munishchouhan Jan 15, 2025
a76ae63
fixed Dockerfile
munishchouhan Jan 16, 2025
6546f05
fixed error
munishchouhan Jan 16, 2025
4a70e0b
change port to 9080
munishchouhan Jan 16, 2025
887c9a7
set typespec version
munishchouhan Jan 16, 2025
ee99ce4
refactored
munishchouhan Jan 20, 2025
ea138a7
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Jan 20, 2025
a6256cb
added stage and dev URL
munishchouhan Jan 20, 2025
1ef6102
openapi port changed to 9080
munishchouhan Jan 20, 2025
84ad4f4
refactored
munishchouhan Jan 20, 2025
32b6bb9
[release docs] bump docs 1.16.8-A0
munishchouhan Jan 20, 2025
ff460cd
[release docs] bump docs 1.16.8-A1
munishchouhan Jan 20, 2025
b9a719b
[release docs] bump docs 1.16.8
munishchouhan Jan 20, 2025
c5c7d85
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Jan 20, 2025
47a54c7
Update .github/workflows/typespec.yml
munishchouhan Jan 21, 2025
7e9af94
Merge branch 'master' into 675-render-api-docs-from-typespec-model
munishchouhan Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/typespec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,26 @@ jobs:
node-version : '20.9.0'

- name : Install tsp
run : npm install -g @typespec/compiler
run : npm install -g @typespec/compiler@0.64.0

- name : Validate tsp files
run : |
cd typespec
tsp install
tsp compile .

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{secrets.TOWER_CI_AWS_ACCESS}}
aws-secret-access-key: ${{secrets.TOWER_CI_AWS_SECRET}}
aws-region: eu-west-1

- name : Login to Amazon ECR
id : login-ecr
uses : aws-actions/amazon-ecr-login@v1

- name: Release OpenAPI docs
if: "contains(github.event.head_commit.message, '[release]')"
run: |
bash typespec/tag-and-push-docs.sh
13 changes: 13 additions & 0 deletions typespec/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM nginx:alpine

# Copy index.html and openapi.yaml to the Nginx html directory
COPY index.html /usr/share/nginx/html/openapi/index.html
COPY tsp-output/@typespec/openapi3/openapi.yaml /usr/share/nginx/html/openapi/openapi.yaml

# Use sed to modify the default Nginx configuration to listen on port 9080
RUN sed -i 's/listen 80;/listen 9080;/' /etc/nginx/conf.d/default.conf

# Expose port 9080
EXPOSE 9080

CMD ["nginx", "-g", "daemon off;"]
28 changes: 28 additions & 0 deletions typespec/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wave API Documentation</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css">
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "openapi.yaml",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
layout: "BaseLayout"
});
window.ui = ui;
};
</script>
</body>
</html>
1 change: 1 addition & 0 deletions typespec/main.tsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "@typespec/http";
import "@typespec/rest";
import "@typespec/openapi3";
import "@typespec/versioning";
import "./routes.tsp";
12 changes: 6 additions & 6 deletions typespec/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "wave",
"version": "1.8.2",
"version": "1.16.7",
"type": "module",
"dependencies": {
"@typespec/compiler": "latest",
"@typespec/http": "latest",
"@typespec/rest": "latest",
"@typespec/openapi3": "latest"
"@typespec/compiler": "0.64.0",
"@typespec/http": "0.64.0",
"@typespec/openapi3": "0.64.0",
"@typespec/rest": "0.64.0"
},
"private": true
}
}
11 changes: 9 additions & 2 deletions typespec/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import "./models/models.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;

@versioned(wave.Versions)
@service({
title: "Wave service",
title: "Wave service"
})
@server("https://wave.seqera.io", "wave endopint")
@server("https://wave.dev-tower.net", "wave dev endpoint")
@server("https://wave.stage-seqera.io", "wave stage endpoint")
munishchouhan marked this conversation as resolved.
Show resolved Hide resolved
@server("https://wave.seqera.io", "wave prod endpoint")
namespace wave {
enum Versions {
v1: "1.16.8",
}
@route("/v1alpha2/container")
interface ContainerService {

Expand Down
42 changes: 42 additions & 0 deletions typespec/tag-and-push-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#
# Wave, containers provisioning service
# Copyright (c) 2023-2024, Seqera Labs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

# Tag and and push the the GitHub repo and Docker images

set -e
set -x

SED=sed
[[ $(uname) == Darwin ]] && SED=gsed

RELEASE=${RELEASE:-$(git show -s --format='%s' | $SED -rn 's/.*\[(release docs)\].*/\1/p')}

if [[ $RELEASE ]]; then
TAG=v$(cat VERSION)

npm install -g @typespec/compiler

cd typespec
tsp install
tsp compile .


docker build -t 195996028523.dkr.ecr.eu-west-1.amazonaws.com/wave/openapi:$TAG .
docker push 195996028523.dkr.ecr.eu-west-1.amazonaws.com/wave/openapi:$TAG
fi
3 changes: 3 additions & 0 deletions typespec/tspconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
emit:
- "@typespec/openapi3"
options:
"@typespec/openapi3":
output-file: openapi.yaml
Loading