fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
MIT License
2.45k stars 118 forks source link

[Bug] Invalid file generated in Python client #2754

Open Daniel-Vetter-Coverwhale opened 5 months ago

Daniel-Vetter-Coverwhale commented 5 months ago

Describe the Bug

An invalid file is being generated, with an empty method.

Information to Reproduce

CLI Version

v0.16.25

Generator Version

0.7.2

Custom Config

I don't think it's custom, but here it is in full

default-group: local
groups:
  local:
    generators:
      - name: fernapi/fern-python-sdk
        version: 0.7.2
        output:
          location: local-file-system
          path: ../generated/sdk/python

Fern Definition

The minimal fern definition required to reproduce the bug.

Unknown

Actual Python SDK

The buggy Python SDK that is produced:

# This file was auto-generated by Fern from our API Definition.

import enum
import typing

T_Result = typing.TypeVar("T_Result")
class OauthScope(str, enum.Enum):
    def visit(self) -> T_Result:
# missing anything in the method body

Expected Python SDK

Honestly not sure. API seems to work fine if I just put pass in there.

# This file was auto-generated by Fern from our API Definition.

import enum
import typing

T_Result = typing.TypeVar("T_Result")

class OauthScope(str, enum.Enum):
    def visit(self) -> T_Result:
        pass

Additional Context

I tried tracking this down, but I don't actually see anything about this in the fern .definition of the API. I'm attaching the full swagger.json. This isn't super urgent, and I don't know if it happens with other openapi specs, but if it does then getting this fixed will make onboarding easier for new folks, as they can run fern and then black/ruff/whatever linting they have set up and the linters won't complain. Also this could be an issue with the spec itself, I'm not sure, but if that's the case maybe fern can let me know what's missing like it did with the other spec issues :)

swagger.json

armandobelardo commented 3 months ago

@Daniel-Vetter-Coverwhale, could you try this on the latest version of the python generator - 0.11.10? There have been a large number of changes since this version! https://github.com/fern-api/fern/blob/main/generators/python/sdk/CHANGELOG.md

Daniel-Vetter-Coverwhale commented 3 months ago

Hey sorry this took me a long time to get back to, my apologies!

I upgraded fern itself to 0.19.24

❯ fern --version
(node:15843) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
0.19.24

and the python generator to 0.8.0

      - name: fernapi/fern-python-sdk
        version: 0.8.0
        output:
          location: local-file-system
          path: ../generated/

but now I'm getting

❯ fern generate --local
(node:15980) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[api]: POST /v1/tenants/{tenantUniqueName}/geofence is marked with x-fern-ignore. Skipping.
[api]: Found 3 errors and 4 warnings. Run fern check --warnings to print out the warnings.
[api]: eventAccess.yml -> service -> endpoints -> getVideoPlayUrl -> examples[0] -> path-parameters
       Example is missing required path parameter "tenantUniqueName"
[api]: eventAccess.yml -> service -> endpoints -> getVideoPlayUrl -> examples[0] -> path-parameters
       Example is missing required path parameter "videoIds"
[api]: eventAccess.yml -> service -> endpoints -> getVideoPlayUrl -> examples[0] -> response
       Expected example to be an object. Example is: undefined

which looks like it's complaining about something in the IR? That op (getVideoPlayUrl) doesn't seem to have any examples, so it makes sense that they would be missing, but doesn't necessarily make sense that that matters.

Sorry again for the late response! I'm using fern with a few other api specs, and it works much better for those. This weird spec might be useful though, since I have encountered many poorly written specs out there in the wild. I appreciate you guys and fern, thanks again!

armandobelardo commented 1 month ago

@Daniel-Vetter-Coverwhale would you be able to share an updated API spec?

Daniel-Vetter-Coverwhale commented 1 month ago

This was still using the same spec as posted in my opening comment