Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastApi generator does not work with structured inputs #5806

Open
aryehklein opened this issue Jan 30, 2025 · 0 comments
Open

FastApi generator does not work with structured inputs #5806

aryehklein opened this issue Jan 30, 2025 · 0 comments
Labels
bug Issues reporting bugs. product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages

Comments

@aryehklein
Copy link
Contributor

aryehklein commented Jan 30, 2025

CLI Version from fern.config.json

0.39.19

Generator & Version from generators.yml

fernapi/fern-fastapi-server@"1.6.0"

Minimal API Specification

TestUpload:
  docs: Test upload
  method: POST
  path: "/test-upload"
  request:
    name: UploadDocumentRequest
    body:
      properties:
        file: file
        body: SystemLocator
  response: string
  errors:
    - errors.BadRequestError
    - errors.NotAuthorizedError
    - errors.InternalServerError

types:
SystemLocator:
key: value

Actual Generated Code

@abc.abstractmethod
async def test_upload(
    self, *, file: fastapi.UploadFile, body: SystemLocator, auth: ApiAuth
) -> str:
    """
    Test upload
    """
    ...

Expected Generated Code

The body is wrong - in a multiform upload FastApi expects a Form field. Having it as is causes a 422 in all cases. When I change my method to

    async def test_upload(self, *, file: UploadFile, body: typing.Optional[typing.Any], auth: ApiAuth) -> None:
 -> str:
        """
        Test upload
        """

The method call works as it bypasses fastapi validation. I think that the abstract method should leverage the Form FastApi integration so this works out of the box

Environment Details (Optional)

No response

@aryehklein aryehklein added bug Issues reporting bugs. product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues reporting bugs. product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages
Development

No branches or pull requests

1 participant