rdmorganiser / rdmo

A tool to support the planning, implementation, and organization of research data management.
https://rdmorganiser.github.io
Apache License 2.0
99 stars 47 forks source link

Replace `django-rest-swagger` with `drf-spectacular` #698

Open afuetterer opened 12 months ago

afuetterer commented 12 months ago

Rationale / Begründung

django-rest-swagger is deprecated since 2019. Should rdmo switch to an alternative openapi library? drf-spectacular looks promising.

Affected

Software group

References / Verweise

afuetterer commented 1 month ago

Using django-rest-swagger

image


Using drf-spectacular

afuetterer commented 1 month ago

@jochenklar @MyPyDavid: Do you know, if the swagger UI used or is this just for convenience?

I want to switch out the deprecated library, that generates 100+ warnings when running the tests.

Is it important to generate the exact same UI under the exact same URL?

jochenklar commented 1 month ago

Hi @afuetterer thanks for the effort! No I don't think we need swagger, I never liked it anyway. But I guess we need something like this, meaning a browsable API explorer thingy.

afuetterer commented 1 month ago

Alright, thanks.

drf-spectacular generates the openapi schema in json/yaml and renders those in swagger/redoc.

I will submit a PR, then you can test it.

afuetterer commented 1 month ago

Regarding the versioning here:

There is the RDMO version, e.g. 2.1.3 or 2.2.0, and there is a URL path versioning api/v1/.

What is the difference here?

Is the "version" of the API always "v1"?

jochenklar commented 1 month ago

Yes, the version is always v1, and its there in case we have another one and need to run them both in parallel. A lot of people say that it is super important to version apis in this way, so I try to do it all the time. An I needed it once.

afuetterer commented 1 month ago
$ python manage.py spectacular --color --file schema.yml --validate
[...]
Schema generation summary:
Warnings: 237 (109 unique)
Errors:   28 (5 unique)
afuetterer commented 1 month ago

This is the swagger schema generated by django-rest-swagger: https://github.com/afuetterer/rdmo/blob/698-drf-spectacular/django-rest-swagger.yaml

npx open-swagger-ui --open django-rest-swagger.yaml
afuetterer commented 1 month ago

What about this repo?

https://github.com/rdmorganiser/rdmo-openapi