Skip to content

Commit

Permalink
Check if open api has been regenerated (#61)
Browse files Browse the repository at this point in the history
## Description, Motivation and Context

Check if the room manager open api is up to date, so every app using
room manager has an up-to-date reference.


## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to
      not work as expected)
  • Loading branch information
czerwiukk authored Oct 7, 2024
1 parent bf711d2 commit 9f42db3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ jobs:

- name: Check typing
run: yarn typecheck

- name: Generate OpenAPI reference 📸
run: yarn gen:openapi ref.yaml

- name: Compare OpenAPI reference 🔦
run: |
RM_PATH=examples/room-manager
if ! cmp --silent "$RM_PATH/openapi.yaml" "$RM_PATH/ref.yaml"; then
echo "OpenAPI spec is out of date. Please run 'yarn gen:openapi' and commit the changes."
exit 1
fi
1 change: 1 addition & 0 deletions examples/room-manager/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openapi.yaml
12 changes: 6 additions & 6 deletions examples/room-manager/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ paths:
/health:
get:
responses:
'200':
"200":
description: Default Response
/api/rooms:
get:
Expand All @@ -27,7 +27,7 @@ paths:
name: peerName
required: true
responses:
'200':
"200":
description: Default Response
content:
application/json:
Expand Down Expand Up @@ -55,7 +55,7 @@ paths:
required:
- peerToken
- url
'410':
"410":
description: Default Response
content:
application/json:
Expand All @@ -70,7 +70,7 @@ paths:
type: string
required:
- error
'500':
"500":
description: Default Response
content:
application/json:
Expand Down Expand Up @@ -99,12 +99,12 @@ paths:
name: roomName
required: true
responses:
'200':
"200":
description: Default Response
/api/rooms/webhook:
post:
responses:
'200':
"200":
description: Default Response
servers:
- url: http://localhost:5004
Expand Down
4 changes: 3 additions & 1 deletion examples/room-manager/scripts/generate-openapi-schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { writeFile } from 'node:fs/promises';
import { fastify } from '../src';

const [fileName] = process.argv.slice(2);

(async () => {
await fastify.ready();

Expand All @@ -9,7 +11,7 @@ import { fastify } from '../src';
}

const schema = fastify.swagger({ yaml: true });
await writeFile('openapi.yaml', schema, { flag: 'w+' });
await writeFile(fileName ?? 'openapi.yaml', schema, { flag: 'w+' });

await fastify.close();
})();
2 changes: 1 addition & 1 deletion examples/room-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { roomsEndpoints } from './rooms';
import { ServerMessage } from '@fishjam-cloud/js-server-sdk/proto';
import healthcheck from 'fastify-healthcheck';
import fastifySwagger from '@fastify/swagger';
import { openapi } from './opanapi';
import openapi from './openapi';

const envToLogger = {
development: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const openapi = {
export default {
openapi: '3.0.0',
info: {
title: 'Room manager',
Expand Down

0 comments on commit 9f42db3

Please sign in to comment.