Skip to content

Commit

Permalink
ci: validation of generated OpenAPI schema (#604) (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Nov 8, 2024
1 parent 48382b6 commit ba15439
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,38 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info

Schema:
needs: Formatting
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y librocksdb-dev libsnappy-dev libsqlite3-dev
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup protoc
uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Write schema
run: cargo run -- server schema --output-file /tmp/openapi.schema.yaml

- name: Compare YAML in git to the one just generated
run: diff openapi.schema.yaml /tmp/openapi.schema.yaml

- name: Validate OpenAPI schema
uses: thiyagu06/openapi-validator-action@v1
with:
filepath: /tmp/openapi.schema.yaml
91 changes: 91 additions & 0 deletions openapi.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
openapi: 3.0.3
info:
title: mehari
description: Variant effect prediction all in Rust
contact:
name: Manuel Holtgrewe
email: [email protected]
license:
name: MIT
version: 0.29.6
paths:
/api/v1/versionsInfo:
get:
tags:
- versions
summary: Query for consequence of a variant.
operationId: versionsInfo
responses:
'200':
description: Version information.
content:
application/json:
schema:
$ref: '#/components/schemas/VersionsInfoResponse'
'500':
description: Internal server error.
content:
application/json:
schema:
$ref: '#/components/schemas/CustomError'
components:
schemas:
Assembly:
type: string
description: |-
Assembly to be passed on the command line.
Copy from annonars with extension to derive `utoipa::ToSchema`.
enum:
- grch37
- grch38
CustomError:
type: object
required:
- err
properties:
err:
type: string
DataVersionEntry:
type: object
description: Specification of data version for a given genome build.
required:
- genome_build
properties:
genome_build:
$ref: '#/components/schemas/Assembly'
version_refseq:
type: string
description: Version of the RefSeq database, if any.
nullable: true
version_ensembl:
type: string
description: Version of the Ensembl database, if any.
nullable: true
SoftwareVersions:
type: object
description: Software version specification.
required:
- mehari
- hgvs_rs
properties:
mehari:
type: string
description: Version of `mehari`.
hgvs_rs:
type: string
description: Version of the `hgvs` crate.
VersionsInfoResponse:
type: object
description: Response of the `/v1/version` endpoint.
required:
- software
- data
properties:
software:
$ref: '#/components/schemas/SoftwareVersions'
data:
type: array
items:
$ref: '#/components/schemas/DataVersionEntry'
description: Data versions specification.

0 comments on commit ba15439

Please sign in to comment.