Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

feat: Feature/swagger options #8

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- development
paths:
- packages/rejs/**
- package-lock.json
- .github/workflows/core.yml

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- development
paths:
- packages/rejs-swagger/**
- package-lock.json
- .github/workflows/swagger.yml

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus
Expand Down Expand Up @@ -131,3 +130,4 @@ dist

.idea
lib

1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/rejs-swagger/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@relab/rejs-swagger",
"version": "1.0.0",
"description": "",
"description": "re.js is a framework built on top of Express that facilitates the development of API endpoints using the capabilities of Typescript and Zod.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -48,7 +48,6 @@
},
"peerDependencies": {
"@asteasolutions/zod-to-openapi": "^6.0.0",
"@relab/rejs": "1.0.0",
"@types/express": "^4.0.0",
"@types/swagger-ui-dist": "^3.0.0",
"express": "^4.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/rejs-swagger/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi'
import { OpenAPIObjectConfig } from '@asteasolutions/zod-to-openapi/dist/v3.0/openapi-generator'
import { UrlSchema } from '@relab/rejs'

Expand All @@ -6,7 +7,8 @@ export type SwaggerOptions = {
version?: string
title?: string
description?: string
options?: OpenAPIObjectConfig
configure?: (registry: OpenAPIRegistry) => void
options?: Partial<OpenAPIObjectConfig>
ui?:
| {
enabled: true
Expand Down
4 changes: 4 additions & 0 deletions packages/rejs-swagger/src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const swagger: (options?: SwaggerOptions) => Middleware = options => conf
if (request.path === swaggerPath) {
const registry = new OpenAPIRegistry()

if (options?.configure) {
options.configure(registry)
}

register(
registry,
configuration.prefix,
Expand Down
2 changes: 1 addition & 1 deletion packages/rejs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@relab/rejs",
"version": "1.0.0",
"description": "",
"description": "re.js is a framework built on top of Express that facilitates the development of API endpoints using the capabilities of Typescript and Zod.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
Expand Down