-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render html from openapi spec generated by typespec (#707)
Render html from openapi spec generated by typespec
- Loading branch information
1 parent
4068c61
commit d3dfee9
Showing
10 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/groovy/io/seqera/wave/controller/ServiceInfoControllerTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 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/>. | ||
*/ | ||
|
||
package io.seqera.wave.controller | ||
|
||
import spock.lang.Specification | ||
|
||
import io.micronaut.http.HttpResponse | ||
import io.micronaut.http.HttpStatus | ||
|
||
/** | ||
* | ||
* @author Munish Chouhan <[email protected]> | ||
*/ | ||
class ServiceInfoControllerTest extends Specification { | ||
|
||
def 'should redirect to /openapi/'() { | ||
given: | ||
def controller = new ServiceInfoController() | ||
|
||
when: | ||
HttpResponse response = controller.getOpenAPI() | ||
|
||
then: | ||
response.status == HttpStatus.MOVED_PERMANENTLY | ||
response.header('Location') == '/openapi/' | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM nginxinc/nginx-unprivileged: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 | ||
|
||
# Expose port 8080 | ||
EXPOSE 8080 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/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)\].*/\1/p')} | ||
|
||
if [[ $RELEASE ]]; then | ||
TAG=v$(cat VERSION) | ||
version=$(cat VERSION) | ||
|
||
cd typespec | ||
sed -i "s/version: 0.0.0/version: $version/" "tsp-output/@typespec/openapi3/openapi.yaml" | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
emit: | ||
- "@typespec/openapi3" | ||
options: | ||
"@typespec/openapi3": | ||
output-file: openapi.yaml |