Skip to content

Commit

Permalink
feat(api): use same schema for input and output
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <jordanshatford@live.com>
  • Loading branch information
jordanshatford committed Aug 28, 2023
1 parent 2c9a76e commit 0be9b1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 134 deletions.
1 change: 1 addition & 0 deletions apps/api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def generate_custom_unique_id(route: routing.APIRoute):
],
version=pyproject_data['version'],
generate_unique_id_function=generate_custom_unique_id,
separate_input_output_schemas=False,
)

allowed_origin = os.environ.get('ALLOWED_ORIGIN', 'http://localhost:5173')
Expand Down
141 changes: 8 additions & 133 deletions apps/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Video-Output"
"$ref": "#/components/schemas/Video"
},
"title": "Response Get Search"
}
Expand Down Expand Up @@ -136,7 +136,7 @@
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Video-Output"
"$ref": "#/components/schemas/Video"
},
"type": "array",
"title": "Response Get Downloads"
Expand Down Expand Up @@ -164,7 +164,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Video-Input"
"$ref": "#/components/schemas/Video"
}
}
},
Expand All @@ -176,7 +176,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Video-Output"
"$ref": "#/components/schemas/Video"
}
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Video-Output"
"$ref": "#/components/schemas/Video"
}
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@
],
"title": "AudioOptions"
},
"Channel-Input": {
"Channel": {
"properties": {
"name": {
"type": "string",
Expand Down Expand Up @@ -473,49 +473,6 @@
],
"title": "Channel"
},
"Channel-Output": {
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"url": {
"anyOf": [
{
"type": "string",
"maxLength": 2083,
"minLength": 1,
"format": "uri"
},
{
"type": "null"
}
],
"title": "Url"
},
"thumbnail": {
"anyOf": [
{
"type": "string",
"maxLength": 2083,
"minLength": 1,
"format": "uri"
},
{
"type": "null"
}
],
"title": "Thumbnail"
}
},
"type": "object",
"required": [
"name",
"url",
"thumbnail"
],
"title": "Channel"
},
"HTTPValidationError": {
"properties": {
"detail": {
Expand Down Expand Up @@ -604,7 +561,7 @@
],
"title": "ValidationError"
},
"Video-Input": {
"Video": {
"properties": {
"id": {
"type": "string",
Expand Down Expand Up @@ -666,7 +623,7 @@
"channel": {
"anyOf": [
{
"$ref": "#/components/schemas/Channel-Input"
"$ref": "#/components/schemas/Channel"
},
{
"type": "null"
Expand All @@ -680,88 +637,6 @@
"url"
],
"title": "Video"
},
"Video-Output": {
"properties": {
"id": {
"type": "string",
"title": "Id"
},
"url": {
"type": "string",
"maxLength": 2083,
"minLength": 1,
"format": "uri",
"title": "Url"
},
"options": {
"allOf": [
{
"$ref": "#/components/schemas/AudioOptions"
}
],
"default": {
"format": "mp3"
}
},
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Title"
},
"duration": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Duration"
},
"thumbnail": {
"anyOf": [
{
"type": "string",
"maxLength": 2083,
"minLength": 1,
"format": "uri"
},
{
"type": "null"
}
],
"title": "Thumbnail"
},
"channel": {
"anyOf": [
{
"$ref": "#/components/schemas/Channel-Output"
},
{
"type": "null"
}
]
}
},
"type": "object",
"required": [
"id",
"url",
"options",
"title",
"duration",
"thumbnail",
"channel"
],
"title": "Video"
}
},
"securitySchemes": {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fastapi==0.101.1
fastapi==0.103.0
sse-starlette==1.6.5
uvicorn==0.23.2
youtube-search-python==1.6.6
Expand Down

1 comment on commit 0be9b1b

@vercel
Copy link

@vercel vercel bot commented on 0be9b1b Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.