forked from koxudaxi/fastapi-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-222
- Loading branch information
Showing
8 changed files
with
216 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/data/expected/openapi/default_template/upload/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# generated by fastapi-codegen: | ||
# filename: upload.yaml | ||
# timestamp: 2020-06-19T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Union | ||
|
||
from fastapi import FastAPI, Request, UploadFile | ||
|
||
from .models import Error | ||
|
||
app = FastAPI( | ||
version='1.0.0', | ||
title='Swagger Petstore', | ||
license={'name': 'MIT'}, | ||
description='API definiton for testing file upload', | ||
servers=[{'url': 'http://petstore.swagger.io/v1'}], | ||
) | ||
|
||
|
||
@app.post( | ||
'/pets/{id}/image/form-data', | ||
response_model=None, | ||
responses={'default': {'model': Error}}, | ||
tags=['pets'], | ||
) | ||
def upload_pet_image_with_form_data( | ||
id: str, file: UploadFile = ... | ||
) -> Union[None, Error]: | ||
""" | ||
Upload image with Form-Data for a pet | ||
""" | ||
pass | ||
|
||
|
||
@app.post( | ||
'/pets/{id}/image/octet-stream', | ||
response_model=None, | ||
responses={'default': {'model': Error}}, | ||
tags=['pets'], | ||
) | ||
def upload_pet_image_with_octet_stream( | ||
id: str, request: Request = ... | ||
) -> Union[None, Error]: | ||
""" | ||
Upload image with octet-stream for a pet | ||
""" | ||
pass |
12 changes: 12 additions & 0 deletions
12
tests/data/expected/openapi/default_template/upload/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# generated by fastapi-codegen: | ||
# filename: upload.yaml | ||
# timestamp: 2020-06-19T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class Error(BaseModel): | ||
code: int | ||
message: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
openapi: "3.0.0" | ||
info: | ||
version: 1.0.0 | ||
title: Swagger Petstore | ||
license: | ||
name: MIT | ||
description: API definiton for testing file upload | ||
|
||
servers: | ||
- url: http://petstore.swagger.io/v1 | ||
paths: | ||
/pets/{id}/image/octet-stream: | ||
post: | ||
summary: Upload image with octet-stream for a pet | ||
operationId: uploadPetImageWithOctetStream | ||
tags: | ||
- pets | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
description: The id of the pet | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
application/octet-stream: | ||
schema: | ||
type: string | ||
format: binary | ||
responses: | ||
'201': | ||
description: empty response | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Error" | ||
/pets/{id}/image/form-data: | ||
post: | ||
summary: Upload image with Form-Data for a pet | ||
operationId: uploadPetImageWithFormData | ||
tags: | ||
- pets | ||
parameters: | ||
- name: id | ||
in: path | ||
required: true | ||
description: The id of the pet | ||
schema: | ||
type: string | ||
requestBody: | ||
content: | ||
multipart/form-data: | ||
schema: | ||
type: string | ||
format: binary | ||
responses: | ||
'201': | ||
description: empty response | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Error" | ||
components: | ||
schemas: | ||
Error: | ||
required: | ||
- code | ||
- message | ||
properties: | ||
code: | ||
type: integer | ||
format: int32 | ||
message: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters