1480 Commits

Author SHA1 Message Date
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
Robbe Sneyders
c3e2e57422 Unpack error handler when registering on middleware (#1695)
Registering error handlers on the async app leads to an error on 3.0.0a5
because the error handlers are not unpacked correctly when being
registered internally.
2023-04-24 16:47:36 +02:00
Ruwann
97e8a8e7f8 Remove context keyword from security handlers (#1690)
Follow-up on #1671 

Since the request context is available globally, we can remove this
complexity from the security handlers ("There should be one-- and
preferably only one --obvious way to do it.")

In addition it seems like there weren't any tests for the context in
security handler functions, and I don't think there's a lot of value in
a test for checking the context in security functions specifically.
3.0.0a5
2023-04-22 22:03:01 +02:00
Robbe Sneyders
1beb0539f5 Inspect middleware parameters before passing in lifespan (#1686)
Fixes #1682 

This PR inspects the parameters of a Middleware class before passing in
the `lifespan` keyword argument. I was doubting to check the class
instead (`isinstance(LifespanMiddleware)`), but that's less flexible if
users want to write custom middleware to handle the lifespan.
2023-04-22 22:01:30 +02:00
Ruwann
e0550e6a90 Add test for security_map argument (#1691)
Follow-up of #1671 

Let me know if there is an easier way doing the test instead of the
current "custom" basic auth.
2023-04-22 21:42:55 +02:00
Robbe Sneyders
7f111505a2 Add add_middleware interface (#1683)
This PR adds an `add_middleware` method to the apps and
`ConnexionMiddleware` to easily add middleware to the stack. Before, the
only way to do this was to pass in a complete middleware stack.

The default position to add the new middleware is right before the
`ContextMiddleware`, which is the final middleware in the stack. Another
position can be selected by passing in a `MiddlewarePosition` enum,
which defines some positions which make sense.

Since we can no longer assume that the whole middleware stack is defined
when initializing the `ConnexionMiddleware`, we need to delay building
the middleware stack until the `ConnexionMiddleware` is actually called.
This also means we need to delay registering the APIs and error
handlers. This is now all done in the `_build_middleware_stack` method.
2023-04-22 21:37:19 +02:00
Robbe Sneyders
bcdd26ba0d Update CLI for 3.0 (#1687)
Fixes #1684
2023-04-21 12:11:38 +02:00
Ruwann
d9b699bf65 Add tests for strict validation in combination with api key in query (#1681)
Continues on the work of #1077 by moving the test fixtures into the
`secure_endpoint` fixture and adding a test for it in
`test_secure_api.py`.

The test will check whether an api key in the query will not lead to an
error when `strict_validation` is enabled.
2023-04-20 19:59:23 +02:00
Ruwann
5b4beeb2ea Make security pluggable (#1671)
Make security pluggable

- [x] Solution for standard security handlers: `security_deny`,
`security_passthrough`, `verify_none`
- [x] HTTP security handlers & overlap with basic from swagger 2
- [x] Do we need a separate handler for each `oauth2` flow?
2023-04-08 18:19:26 +02:00
Robbe Sneyders
55e376f816 Fix stream replay in validators (#1678)
The current implementation of replaying the stream will always replay
the first message. This PR fixes this by progressing through the
messages with each call.
3.0.0a4
2023-03-30 22:12:56 +02:00
Andrew Chong
8cebebc3a4 Fix examples links in security doc page (#1677)
Contributes to #1531 

The links in security doc were pointing at an old repo and folders.
These links could be changed down the road to use relative paths since
they point to the repo internally.
3.0.0a3
2023-03-24 10:55:21 +01:00
Robbe Sneyders
79c0852c93 Add lifespan middleware (#1676)
This PR adds a new middleware to handle lifespan events.

I added this as a separate middleware so it is encapsulated and aligned
for both the `FlaskApp` and `AsyncApp`. It leverages a Starlette
`Router` to register and call the lifespan handler.
2023-03-23 19:11:43 +01:00
Robbe Sneyders
8a85a4fe01 Pass through lifespan events (#1673)
Fixes #1672

Lifespan events were being intercepted by the swagger UI middleware. We
should let them pass through.
2023-03-13 23:34:00 +01:00
Robbe Sneyders
cd64611747 Add explicit asgiref dependency (#1667)
We use `asgiref` as a direct dependency

ab94e2aaa6/connexion/decorators/main.py (L7)

So should add it explicitly as well.

This issue is hidden in our tests since we install all extras. To
prevent this, we need to address
https://github.com/spec-first/connexion/issues/1389.
3.0.0a2
2023-03-06 22:19:13 +01:00
Robbe Sneyders
e9b28d486e Update Operations to act as wrapper of wrapped view function (#1669)
Fixes #1666 

The `FlaskOperation` and `AsyncOperation` classes act as decorators for
their wrapped view functions, so their metadata should reflect this,
similar to what `functools.wraps` does.
2023-03-06 21:47:36 +01:00
Robbe Sneyders
4383c5363f Delay import error for optional flask depencendy (#1668)
This PR delays import errors for the optional Flask dependency, so you
can use the AsyncApp without Flask installed.

This issue is hidden in our tests since we install all extras. To
prevent this, we need to address
https://github.com/spec-first/connexion/issues/1389.
2023-03-06 21:45:56 +01:00
Robbe Sneyders
291d9b0139 Update docs index page (#1665)
Contributes to https://github.com/spec-first/connexion/issues/1531

This PR updates the index page for Connexion 3. We'll need to update the
content table as we go.
2023-03-06 21:44:56 +01:00
Robbe Sneyders
db78b68062 Fix and extend v3 documentation (#1664) 2023-03-06 20:01:46 +01:00
Radhakrishna Sanka
ab94e2aaa6 Update quickstart.rst to include example of passing server arguments (#1645)
Changes proposed in this pull request:
- Updated the docs such that it comes with an example for passing server
arguments and serving static files

---------

Co-authored-by: Ruwann <ruwan.lambrichts@ml6.eu>
2023-03-03 10:12:28 +01:00
Robbe Sneyders
c257f04806 Fix ReadTheDocs config for Poetry (#1663) 2023-03-03 09:21:54 +01:00
Robbe Sneyders
6d8c297efc Fix filter pattern in release pipeline (#1659) 3.0.0a1 2023-03-02 23:44:41 +01:00
Robbe Sneyders
108d59f97a Run release pipeline for pre-releases as well (#1658) 2023-03-02 23:23:09 +01:00
Robbe Sneyders
125d3089e6 Add high-level documentation for 3.0 (#1646)
I'd like to cut an alpha release for 3.0 while we further polish the
code base and update the documentation. This way users can already test
3.0 and provide feedback.

This PR adds some very high-level documentation to serve as a starting
point for users to test the alpha version.
2023-03-02 23:17:32 +01:00
Robbe Sneyders
4f6ddfb0a0 Add jsonifier as argument to app / api (#1656)
This PR adds a `jsonifier` argument to the app and api to align it with
other customization options. We also no longer pass it via the operation
object, which brings us closer to operations as data class only.
2023-03-02 22:00:47 +01:00
Robbe Sneyders
1cb5f83181 Don't return 400 when read-only property is provided (#1655)
Fixes #942 

No longer return 400 if a read-only property is provided, as discussed
in the issue. We still raise an error if write-only properties are
included in the response and response validation is enabled.

I also changed how read-/write-only works in combination with
`required`. Previously, `required` would not be overwritten by
read-/write-only. Now we just follow the spec to the letter:
- required and read-only: must be included but must be ignored by the
server
- required and write-only: impossible to achieve, but I also don't see
how this combination could make sense
- read-only: may be included but must be ignored by server
- write-only: must not be included by server
2023-03-02 22:00:28 +01:00
Robbe Sneyders
b28cf09a0c Enable response mimetype validation for non-error responses (#1654)
Addresses a todo left in the code.

We only validate the mimetype if the spec defines which mime-types it
produces, and only for non-error responses.
2023-03-02 21:59:50 +01:00
Robbe Sneyders
50cfc83ea5 Create abstract validator classes (#1653) 2023-03-02 21:59:01 +01:00
Robbe Sneyders
4e8e57ed13 Create AbstractResponseBodyValidator class 2023-03-01 23:54:11 +01:00
Robbe Sneyders
3e733df181 Create AbstractRequestBodyValidator class 2023-03-01 23:54:01 +01:00
Robbe Sneyders
969c1460e6 Enforce required RequestBody (#1652)
Fixes #878 
Fixes #1317
2023-02-25 16:40:11 +01:00