Commit Graph

1459 Commits

Author SHA1 Message Date
Aurélien Joga
095ae897a5 Fix middleware doc example (#1796)
I'm starting to use the project with the newly release 3 version.


70084bcc4c/docs/middleware.rst (L115-L120)

It seems this example is not correct. 

1. missing import for SecurityMiddleware
2. `ConnexionMiddleware.default_middlewares` is a list of classes, not
class instances: the filtering never happen.
2023-11-08 23:17:30 +01:00
Robbe Sneyders
70084bcc4c Fix FlaskApp exception handlers (#1788)
Fixes #1787 

In the `FlaskApp`, the error handlers were still registered on the
underlying Flask app instead of on the `ExceptionMiddleware`, which led
to them not following the documented behavior.

The documentation was also incorrect about ignoring error handlers
registered on the flask application. We are only ignoring the default
error handlers registered by Flask itself.

This is a breaking change, however, since this functionality was not
following the documented behavior, and 3.0.0 was only recently released,
I propose to release this as a patch version.
3.0.1
2023-11-06 19:00:46 +01:00
Robbe Sneyders
55bdfbaa70 Improve ASGI server documentation (#1791)
Discussions in #1757 indicate that we should document this more clearly.
2023-11-06 18:49:43 +01:00
Robbe Sneyders
a910709606 Correctly document keys available in context (#1792)
Fixes #1780
2023-11-06 18:36:23 +01:00
Robbe Sneyders
26d1b84242 Add CORS documentation (#1790)
Fixes #1785
2023-11-06 18:35:44 +01:00
Robbe Sneyders
bcf4c63b32 Fix fern link in docs (#1782) 2023-11-03 00:28:12 +01:00
Robbe Sneyders
c69e5977d9 Add Fern sponsor (#1779) 2023-11-03 00:14:35 +01:00
Robbe Sneyders
d972eae864 Add 3.0 announcement (#1774)
Final update for the 3.0 announcement on our docs.
3.0.0
2023-11-02 11:22:30 +01:00
Robbe Sneyders
f2ee190945 Fix images on PyPI (#1773)
The images are not showing correctly on
[test.pypi](https://test.pypi.org/project/connexion/)
2023-11-01 23:45:03 +01:00
Robbe Sneyders
0772056e68 Convert README from rst to md (#1772)
rst lacks different features on both Github and PyPI, making it
difficult to build an rst README that will be rendered well on both.
[The release pipeline was failing due to
this.](https://github.com/spec-first/connexion/actions/runs/6724758517/job/18277703972)
2023-11-01 23:10:20 +01:00
Robbe Sneyders
5fcda360a9 Switch back from py-swagger-ui to swagger-ui-bundle (#1756)
Tested with `swagger-ui-bundle==1.1.0` from Test PyPI.

Opening this as a draft PR, since I didn't publish `swagger-ui-bundle`
to the main PyPI yet, which I would like to do shortly before we release
Connexion 3.

Before Connexion 2.8, the `swagger_ui_bundle` version didn't have an
upper bound. So if anyone runs into any issues because of this update,
I'd rather have them come look for answers when Connexion 3 is out.
2023-11-01 21:26:56 +01:00
Robbe Sneyders
bd704d2aec Update v3 documentation for release (#1771) 2023-11-01 21:11:02 +01:00
Robbe Sneyders
989b5f7f2c Update readme (#1769)
Contributes to #1531

---------

Co-authored-by: Ruwan <ruwan.lambrichts@ml6.eu>
2023-11-01 20:54:28 +01:00
Tzu-ping Chung
9c02fdfa74 Improve JSON req error on disallowed empty body (#1761)
Fixes #1152.

Currently, when a request body is empty, the JSON request validator
would parse it into None, which is later passed down to the JSON Schema
validator. However, jsonschema's validation error message for this case
(when nullable is false) "None is not of type 'object'" is not
particularly friendly to either the API user, nor the website developer.

This change adds a specific check before the None value is passed to
jsonschema to emit a better error message directly.

I also added some drive-by improvements on function argument typing
since _validate in validators don't seem to expect receiving None, but
_parse (the result of which is passed to _validate) is totally allowed
to return None (or anything really). This does not seem to reflect the
logic well.

I’m not exactly sure if this is the best way to do this in Connexion
3.x. [We do have a patch in Connexion 2.x to achieve a similar
effect](e89a7eeea6)
so if anyone understands how the two implementations correspond please
tell me whether the two do the same thing 🙂

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2023-11-01 20:53:07 +01:00
Robbe Sneyders
e7dc56c476 Add new authors' copyright notice (#1770)
This PR adds a copyright notice for the new authors / maintainers of
connexion. It also reformats the license / notice files as prescribed by
the license.
2023-11-01 20:31:59 +01:00
Robbe Sneyders
a7584a6113 Import WSGIDecorator under connexion.decorators (#1768) 2023-11-01 15:27:12 +01:00
Robbe Sneyders
c1ef3f4e3a Add gunicorn with uvicorn workers to docs (#1766)
Fixes #1755
2023-10-31 20:08:17 +01:00
Robbe Sneyders
cbeac6f2c1 Update security docs (#1764)
Contributes to #1531
2023-10-31 20:08:04 +01:00
Robbe Sneyders
17aa31a7ab Remove cookbook docs and sort index better (#1765)
Contributes to #1531
2023-10-30 20:54:59 +01:00
Robbe Sneyders
99c7a13b53 Update cli docs (#1763)
Contributes towards #1531
3.0.0a8
2023-10-29 14:23:21 +01:00
Robbe Sneyders
4556779343 Fix CLI and drop click dependency (#1762) 2023-10-29 11:34:55 +01:00
Robbe Sneyders
d8ceb52822 Update Exceptions documentations (#1758)
Contributes towards #1531
2023-10-29 09:58:05 +01:00
Robbe Sneyders
452ffc7676 Add testing documentation (#1760)
Contributes towards https://github.com/spec-first/connexion/issues/1531
2023-10-29 09:40:43 +01:00
Robbe Sneyders
77a63a07ef Add lifespan documentation (#1759)
Contributes towards https://github.com/spec-first/connexion/issues/1531
2023-10-29 09:40:16 +01:00
Robbe Sneyders
b9ba13cde5 Centralize error handling in ExceptionMiddleware (#1754)
I was writing the documentation on exception handling, and I noticed
that it was very hard to explain our current behavior.

Error handlers can be registered either on the internal Flask app (not
the Starlette one) or on the Connexion app, which leads to some
undefined (actually just really hard to explain) behavior. Eg.
- Registering error handlers on a status code would capture
`starlette.HTTPException` errors on the Connexion app, and
`werkzeug.HTTPException` errors on the Flask App, which means that
registering an error handler on a status code doesn't catch all the
errors with that status code.
- Flask does some default error handling which leads to some exceptions
never reaching the error handlers registered on the Connexion app.

So I made the following changes:
- Replaced the default error handlers we registered on the Flask app
with a default handler on the `ExceptionMiddleware` that takes into
account other handlers registered on status codes.
- Configured Flask to propagate exceptions instead of catching them.
- Abstracted away the Starlette `Request` and `Response` types, so users
can and must now use `ConnexionRequest`
  and `ConnexionResponse` types in error handlers.
- Renamed the `ASGIRequest` class to `ConnexionRequest` since it is the
only Request class part of the high level
  Connexion interface.

We could also rename `ConnexionRequest` and `ConnexionResponse` to just
`Request` and `Response`. Wdyt?
2023-10-29 09:37:54 +01:00
Robbe Sneyders
1b72019b1b Create FUNDING.yml (#1753)
Add Github Sponsors to side panel.

Fixes #1573
2023-10-23 23:11:18 +02:00
Robbe Sneyders
a210917b46 Drop Python 3.7 in favor of 3.11 and 3.12 (#1752)
Python 3.7 is end of life. We should support the newer versions instead.

I also changed tox to only run against the minimum dependency versions
on the lowest Python version, since this should lead to the lowest
versions over all Python versions, and hopefully helps speed up our
pipelines :)
2023-10-23 23:11:06 +02:00
Ruwann
79fd9edfb8 Feature/get delete body (#1712)
Fixes #1689 

Changes proposed in this pull request:

 - Pass through request body in case of `GET` and `DELETE` requests

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
2023-10-23 22:24:47 +02:00
Robbe Sneyders
7eb43f133d Add context documentation (#1747)
Contributes towards #1531 

Fixes #937
2023-10-22 22:51:18 +02:00
Robbe Sneyders
3ef9a76590 Remove debug argument from example (#1749)
Small fix
2023-10-22 22:41:21 +02:00
Robbe Sneyders
655ea430ed Add validation documentation (#1743)
Contributes to #1531
2023-10-17 23:57:06 +02:00
Robbe Sneyders
41c525c52c Support multiple APIs with same base path (#1736)
Fixes #1542 
Fixes #1724 

Cherry-picked some commits from #1598.

---------

Co-authored-by: Leonardo Festa <4375330+leonardofesta@users.noreply.github.com>
2023-10-17 23:40:13 +02:00
Robbe Sneyders
17fcad0c30 Update response handling documenation (#1742)
Contributes to #1531
2023-10-16 23:51:21 +02:00
Robbe Sneyders
b102ad9f6c Update request handling documentation (#1741)
Contributes to #1531
2023-10-15 12:59:58 +02:00
Robbe Sneyders
415d383740 Add swagger-ui docs and clean up swagger-ui options (#1739)
Contributes to #1531
2023-10-13 20:33:22 +02:00
Heinz-Alexander Fuetterer
8459c614fd chore: fix typos (#1740)
Changes proposed in this pull request:

 - fix some minor typos
2023-10-12 23:30:23 +02:00
Robbe Sneyders
abc1da750e Update routing documentation (#1738)
Works towards #1531 

Some parts of the old outing docs will need to be included on the
`parameters` and `swagger-ui` pages which we still need to add.
2023-10-12 01:37:45 +02:00
Robbe Sneyders
382fbca145 Make middleware_app property private (#1737)
So it doesn't show up in documentation.
2023-10-07 01:05:23 +02:00
Robbe Sneyders
649c7ec75e Bump starlette (#1734)
Fixes https://github.com/spec-first/connexion/issues/1728
2023-10-06 15:46:03 +02:00
Ruwann
3fa9f3bf3d Bugfix/basepath (#1716)
Working towards #1709 

I think we're almost there, some tests I did are now working properly.

Would love to get some feedback/ideas on the implementation and the
tests :)
3.0.0a7
2023-07-01 11:08:21 +02:00
Julien Schuermans
5e9447c3fd Fix typo (#1713)
Fixes a translation error in the `AbstractApp.add_api` docstring
2023-06-18 17:38:09 +02:00
Ruwann
59a09c7c7f Use repr for error logging (#1711)
Follow-up on #1708
([comment](https://github.com/spec-first/connexion/pull/1708#issuecomment-1581196226))

As mentioned there, there is a `__repr__` but not a `__str__`, leading
to an empty log message (for HTTPExceptions).

An example when running the dev server (previously the first line would
just be an empty line):
```
HTTPException(status_code=404, detail='Not Found')
INFO:     127.0.0.1:33538 - "GET /swaggers/ui/ HTTP/1.1" 404 Not Found
```

However, I would also be fine with just removing the logging here as
`HTTPException`s can be part of the normal flow, without indicating an
actual application error (case in point: raising a `Not Found`
exception)
2023-06-13 23:00:33 +02:00
Robbe Sneyders
55f3c59044 Deepcopy only headers in validator (#1710)
Fixes the failing pipeline.

I don't understand the underlying issue completely, but It's related to
[this
code](https://github.com/encode/starlette/compare/0.27.0...0.28.0#diff-87bccafe494bc79680d9d8f57ea797733354b076aa411c0e2bd63f5b4039f71fR51-R54)
added in starlette 0.28. This makes the scope unpicklable in some cases,
leading to an error when trying to deepcopy it.

I replaced the deepcopy of the whole scope with just a deepcopy of the
headers, since this is the only part we're chaning.
2023-06-11 11:01:52 +02:00
Robbe Sneyders
fcd4e66ec6 Add middleware documentation (#1706)
Contributes towards https://github.com/spec-first/connexion/issues/1531

This PR adds a documentation page on middleware.
2023-06-08 00:15:28 +02:00
Ruwann
a34da315db Add traceback info to common error handler (#1708)
When an internal server error
occurs, the logged error is not really useful for the user.
For example, a `KeyError` will only print the missing key instead of the
full stacktrace and error.

Adding it to the common error handler as that one is meant to catch all
remaining errors, `HTTPException`s are handled by another error handler.
2023-06-01 11:06:59 +02:00
Robbe Sneyders
0c0c517cf6 Update quickstart documentation (#1701)
Contributes towards #1531

Updates the quickstart documentation for v3. I removed some more
detailed stuff that I don't think belongs on this page.
2023-05-09 22:22:52 +02:00
Robbe Sneyders
ab54842bb2 Improve and fix docs index page (#1700)
Contributes towards #1531 

Improves the high level explanation of Connexion and fixes broken links
on the index page.
2023-05-09 21:11:49 +02:00
Marcin Lulek
fc1f0df05d Move from caret to inequality requirements (#1704)
Fixes # .
I want to use connexion with newer Starlette


Changes proposed in this pull request:

 - Loosen requirements on starlette version

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@ml6.eu>
2023-05-09 20:24:29 +02:00
Robbe Sneyders
15fe2eda8f Fix add_middleware enum comparison (#1698)
Fixes #1697

Because of a wrong comparison against the position `Enum`, middleware
was not actually being added to the stack via `add_middleware`. This PR
fixes this, adds a warning when the middleware position cannot be found,
and adds a test.
3.0.0a6
2023-04-24 18:09:57 +02:00
Ruwann
128a8e073f Use logger error instead of exception (#1692)
Fixes the `Nonetype: None` issue that shows up in the logging.

It is caused by using `logging.exception` while not in an exception
handler.

I don't know whether including the full traceback makes sense in the
logging, but that could also be possible by adding `exc_info=exc`
2023-04-24 16:48:36 +02:00