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

fix: repair how multiple examples are declared in web_api #243

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

joanise
Copy link
Member

@joanise joanise commented Oct 2, 2024

Before fastapi 0.99, we could declare multiple examples with

examples=[{"key1": ..., "key2": ...}]

Now, examples no longer accept keys or metadata, just a list of plain examples.

Since fastapi 0.103, using openapi_examples instead restores the old key and metadata functionality.

See https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter for details.

PR Goal?

Make the examples for /assemble work again on https://readalong-studio.herokuapp.com/api/v1/docs#/default/assemble_assemble_post

Fixes?

Currently, the proposed example is invalid:

image

This PR brings it back to what we used to have:

image

Feedback sought?

sanity checking

Priority?

low

Tests added?

n/a

How to test?

    pip install uvicorn
    cd readalongs/
    DEVELOPMENT=1 uvicorn readalongs.web_api:web_api_app --reload

then navigate to
http://localhost:8000/api/v1/docs#/default/assemble_assemble_post
and see the two examples being proposed instead of the big invalid block.

Confidence?

high

Version change?

no

Before fastapi 0.99, we could declare multiple examples with

    examples=[{"key1": ..., "key2": ...}]

Now, examples no longer accept keys or metadata, just a list of plain examples.

Since fastapi 0.103, using openapi_examples instead restores the old key and
metadata functionality.

See https://fastapi.tiangolo.com/tutorial/schema-extra-example/#using-the-openapi_examples-parameter
for details.
Copy link

semanticdiff-com bot commented Oct 2, 2024

Review changes with SemanticDiff.

Analyzed 1 of 2 files.

Overall, the semantic diff is 95% smaller than the GitHub diff.

Filename Status
requirements.min.txt Unsupported file format
✔️ readalongs/web_api.py 94.2% smaller

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.12%. Comparing base (3cab240) to head (3fe116b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #243   +/-   ##
=======================================
  Coverage   87.12%   87.12%           
=======================================
  Files          21       21           
  Lines        1786     1786           
  Branches      323      323           
=======================================
  Hits         1556     1556           
  Misses        191      191           
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joanise joanise requested review from roedoejet and dhdaines October 2, 2024 12:49
@joanise joanise merged commit eec5662 into main Oct 3, 2024
8 checks passed
@joanise joanise deleted the dev.ej/fix-api-examples branch October 3, 2024 11:15
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.

1 participant