Skip to content

Commit

Permalink
feat: init openapi distribution
Browse files Browse the repository at this point in the history
Motivation:
We want to publish our API in the public documentation.

Modifications:
 * Copy yaml from internal project
 * configure build and release workflows

Result:
When a version is released, create a release with asset in GitHub
  • Loading branch information
Isammoc committed Oct 20, 2023
1 parent 6dd5317 commit 7949011
Show file tree
Hide file tree
Showing 20 changed files with 1,687 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: pages

on:
push:
branches: [$default-branch]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pages: write
id-token: write

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '21'
cache: 'sbt'

- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: Preprocess with SBT
run: >
sbt
'set openapi / Preprocess / target := (openapi / target).value / "public" / "openapi"'
'openapi / Preprocess / preprocess'
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./openapi/target/public

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
12 changes: 12 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ Compile / packageBin / mappings := {
smithyFiles ++ defaultMappings
}
Compile / unmanagedSourceDirectories += sourceDirectory.value / "main" / "smithy"

lazy val openapi = (project in file("openapi"))
.enablePlugins(PreprocessPlugin)
.settings(
Preprocess / sourceDirectory := sourceDirectory.value / "main" / "openapi",
Preprocess / preprocessRules := Seq(
("API_URL_PLACEHOLDER".r, _ => "https://cloud.gatling.io/"),
("VERSION_PLACEHOLDER".r, _ => version.value)
),
Preprocess / preprocessIncludeFilter := "*.yaml",
Preprocess / target := target.value / "openapi",
)
93 changes: 93 additions & 0 deletions openapi/src/main/openapi/common/components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Requests
requests:

# Responses
responses:

Unauthorized:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/schemas/Error'
examples:
AccessUnauthorized:
value:
error: "invalid_request"
error_description: "i.g.f.a.s.UnauthorizedException$: Access unauthorized"

Errors:
description: Error or Validation Error
content:
application/json:
schema:
$ref: '#/schemas/Errors'
examples:
Error:
$ref: '#/examples/Error'


Error:
description: Error
content:
application/json:
schema:
$ref: '#/schemas/Error'
examples:
Error:
$ref: '#/examples/Error'

ConflictError:
description: Error
content:
application/json:
schema:
$ref: '#/schemas/Error'
example:
error: "invalid_request"
error_description: "i.g.f.a.s.RepositoryNameConflictException: There's already a X with the name Y"

# Schemas
schemas:
Errors:
oneOf:
- $ref: '#/schemas/Error'

Error:
type: object
properties:
error:
type: string
error_description:
type: string

CustomDictionary:
type: object
additionalProperties:
type: string
example:
customProperty: "value"

# Examples
examples:

Error:
value:
error: "invalid_request"
error_description: "description"

parameters:
run:
name: run
in: query
required: true
schema:
type: string
description: "run ID available using /runs API or by clicking on the clipboard icon in the runs table"
simulation:
name: simulation
in: query
required: true
schema:
type: string
description: "Simulation ID available using /simulations API or by clicking on the clipboard icon in the simulations table"
16 changes: 16 additions & 0 deletions openapi/src/main/openapi/default/path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ping:
get:
summary: Ping the server
description: |
Check that the server is responding.
No permission, no authentication needed.
tags:
- Default
responses:
'200':
description: The server pinged back
content:
application/json:
schema:
type: object
26 changes: 26 additions & 0 deletions openapi/src/main/openapi/info/components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
responses:
InfoResponse:
type: object
description: Server informations
required:
- versions
properties:
versions:
type: object
description: Versions supported
required:
- java
properties:
java:
$ref: '#/responses/VersionSupported'

VersionSupported:
type: object
description: Bound versions
properties:
min:
type: string
description: Minimum version supported
max:
type: string
description: Maximum version supported
11 changes: 11 additions & 0 deletions openapi/src/main/openapi/info/path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
info:
get:
summary: Get server informations
tags:
- Info
responses:
'200':
content:
application/json:
schema:
$ref: 'components.yaml#/responses/InfoResponse'
82 changes: 82 additions & 0 deletions openapi/src/main/openapi/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
openapi: 3.0.0
info:
title: Gatling Enterprise Cloud API
description: Documentation of the public Gatling Enterprise Cloud API. To use this API you will need to generate an API token.
version: 'VERSION_PLACEHOLDER'
servers:
- url: '{API_URL}/api/public'
variables:
API_URL:
default: API_URL_PLACEHOLDER
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: authorization
paths:
# Default
/ping:
$ref: 'default/path.yaml#/ping'

# Simulation
/simulations:
$ref: 'simulation/path.yaml#/simulations'
/simulations/{simulationId}:
$ref: 'simulation/path.yaml#/simulations.one'
/simulations/{simulationId}/classname:
$ref: 'simulation/path.yaml#/simulations.one.classname'
/simulations/team:
$ref: 'simulation/path.yaml#/simulations.team'
/simulations/start:
$ref: 'simulation/path.yaml#/simulations.start'
/simulations/abort:
$ref: 'simulation/path.yaml#/simulations.abort'
/simulations/abortAll:
$ref: 'simulation/path.yaml#/simulations.abortAll'
/summaries/requests:
$ref: 'simulation/path.yaml#/summaries.requests'

# Runs
/runs:
$ref: 'runs/path.yaml#/runs'
/run:
$ref: 'runs/path.yaml#/run'
/injectors:
$ref: 'runs/path.yaml#/injectors'
/remotes:
$ref: 'runs/path.yaml#/remotes'
/hostnames:
$ref: 'runs/path.yaml#/hostnames'
/scenarios:
$ref: 'runs/path.yaml#/scenarios'
/groups:
$ref: 'runs/path.yaml#/groups'
/requests:
$ref: 'runs/path.yaml#/requests'
/metrics:
$ref: 'runs/path.yaml#/metrics'
/series:
$ref: 'runs/path.yaml#/series'

# Packages
/artifacts:
$ref: 'pkgs/path.yaml#/packages'
/artifacts/{packageId}:
$ref: 'pkgs/path.yaml#/package'
/artifacts/{packageId}/content:
$ref: 'pkgs/path.yaml#/packages.upload'

# Teams
/teams:
$ref: 'teams/path.yaml#/teams'

# Locations
/pools:
$ref: 'pools/path.yaml#/pools'
/search/private-locations:
$ref: 'private-locations/path.yaml#/private-locations'

# Info
/info:
$ref: 'info/path.yaml#/info'
Loading

0 comments on commit 7949011

Please sign in to comment.