fern-api / fern

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

[Bug] CLI fails to reload local dev env with no context when auth is set as Bearer in api.yml and no auth scheme is set #3796

Open aidanhchau opened 1 month ago

aidanhchau commented 1 month ago

Describe the bug

Pretty much title. In the api.yml file, when setting the auth: parameter to something like Bearer, where the generator is expecting a subsequent

auth-schemes:
    Bearer: ...

but none is provided, the cli docs dev tool will print Failed to reload because of validation errors: and nothing else.

To reproduce

Steps to reproduce the behavior:

  1. Run the command fern docs dev to set up local dev environment with auto reload
  2. Write an api.yml file with an auth: set to a capitalized word (as opposed to a lowercase, i.e. Bearer vs bearer) with no auth-schemes: specified.
  3. CLI tool will reload and state Failed to reload because of validation errors: with no additional context, which makes this issue hard to debug.

Example api.yml:

name: api
auth: Bearer
error-discrimination:
  strategy: status-code
display-name: Example API
environments:
  Staging:
    docs: This is the staging environment for testing!
    url: http://api.exampleservice.com
default-environment: Staging

Expected behavior

I expect context in the error thrown by the cli pointing me to the api.yml file and telling me i have no auth-scheme specified.

Screenshots

image

CLI Version

0.30.0

aidanhchau commented 1 month ago

this seems to be an issue in many other cases of invalid fern definition.

for example, when an invalid type is supplied (int instead of the correct, integer) the cli will provide no context as to why and will show the same error: Failed to reload because of validation errors:

aidanhchau commented 1 month ago

Actually, issue can be easily resolved if the user just runs fern check --warnings. Was just expecting some context around the Failed to reload because of validation errors: due to the colon. Perhaps can change the error message to instruct the user to run fern check --warnings or provide some context after the colon? @dsinghvi feel free to close the issue though.