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

feat: roll openapi json into fastapi #359

Merged
merged 25 commits into from
Feb 8, 2024

Conversation

pawel-kmiecik
Copy link
Contributor

This PR:

  • bumps pydantic to 2.5.x and removes it from explicit dependencies list (will be managed by fastapi)
  • introduced Form params description in the code, which will form openapi and swagger documentation
  • rolled back some openapi customizations
  • keeps backward compatibility for passing parameters in form of list[str] (will not be shown in the documentation)

@awalker4 awalker4 self-requested a review January 29, 2024 15:17
@pawel-kmiecik pawel-kmiecik marked this pull request as draft January 29, 2024 15:25
@pawel-kmiecik pawel-kmiecik marked this pull request as ready for review January 31, 2024 10:34
@pawel-kmiecik
Copy link
Contributor Author

@awalker4 should I remove openapi.json file from the repository then?

multipage_sections: bool
new_after_n_chars: Optional[int]

@classmethod
Copy link
Collaborator

@awalker4 awalker4 Feb 7, 2024

Choose a reason for hiding this comment

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

I take it this is for the backwards compatibility? Can we have a comment here to clarify how new params should be added (assuming they do not need to go into as_form)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for backward compatibility I added:

BeforeValidator(SmartValueParser[List[str]]().value_or_first_element),

In old fields that expected values both as a single value or as an element of a list.
The SmartValueParser will extract the first element from the list if the expected type is not a container.
SmartValueParser is a generic class and is parametrized with the expected type - in the above example its List[str]
You can check its tests to see how it's working:
SmartValueParser tests
Deprecated API tests (with params passed as lists)

prepline_general/api/openapi.py Outdated Show resolved Hide resolved
@awalker4
Copy link
Collaborator

awalker4 commented Feb 7, 2024

I'm getting this error locally - any idea what happened?
Screenshot 2024-02-07 at 11 19 48 AM

@awalker4
Copy link
Collaborator

awalker4 commented Feb 7, 2024

@awalker4 should I remove openapi.json file from the repository then?

Yes please!

@pawel-kmiecik
Copy link
Contributor Author

I'm getting this error locally - any idea what happened? Screenshot 2024-02-07 at 11 19 48 AM

Should be fixed now, I removed openapi.json static file as well.

@pawel-kmiecik pawel-kmiecik merged commit 561b9d8 into main Feb 8, 2024
6 checks passed
@pawel-kmiecik pawel-kmiecik deleted the pawel/roll-openapi-json-into-fastapi branch February 8, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants