Skip to content

OAS 3.0 schema generation #772

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

Merged
merged 16 commits into from
Oct 30, 2020
Merged

Conversation

keyz182
Copy link
Contributor

@keyz182 keyz182 commented Feb 20, 2020

Fixes #604
Fixes #644

Description of the Change

Extends DRF >= 3.12's generateschema to produce a jsonapi-formatted OAS schema document.
Builds on @n2ygk's work in #689

  • Updated to latest DJA version

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@keyz182
Copy link
Contributor Author

keyz182 commented Feb 20, 2020

There are some TODOs left from @n2ygk's work that I'm unsure of, and/or too unfamiliar to understand. However, for initial support for OAS 3.0, it is working well.

@keyz182 keyz182 requested a review from sliverc February 20, 2020 17:55
@n2ygk
Copy link
Contributor

n2ygk commented Mar 2, 2020

@keyz182 I will try to take a look at this later this week. Meanwhile, I note there's ongoing activity w.r.t. openapi generateschema happening upstream at DRF including a bit of flaming :-) so you may want to build against DRF-master. (I haven't looked at your work yet, so maybe you are already doing this.)

@sliverc sliverc changed the title Continuation of #689 - OAS 3.0 schema generation OAS 3.0 schema generation Mar 8, 2020
sliverc
sliverc previously requested changes Mar 8, 2020
Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up. It will be great to have OAS in DJA. All in all is this PR still very big. I have tried to go through it but I am sure I have overlooked things. So far I haven't looked at the tests yet but just the implementation because of lack of time. Once my comments are addressed I will need to review again anyway.

All in all when you look through the PR again it is important that you could look at:

  • what code blocks are really necessary for basic OAS support (one comment I have added concerning this but there might be more). All what can be moved to a later PR makes this PR be approved quicker.
  • update with upstream code. It seems upstream has moved quite a bit and this PR might be simplified therefore (some comments I have added concerning this).

@keyz182
Copy link
Contributor Author

keyz182 commented Mar 9, 2020

Thanks for the feedback @sliverc - I'll try to get back and address your comments later this week (I have some other priorities to start this week off).

@n2ygk
Copy link
Contributor

n2ygk commented Apr 11, 2020

FYI DRF 3.12 milestone continues to develop OAS schema definition

Especially useful is this documentation

@keyz182
Copy link
Contributor Author

keyz182 commented Apr 14, 2020

Sorry - given current events, and new priorities at work, I'm not going to be able to address your concerns just now @sliverc. I will get back to it though.

@auvipy
Copy link
Contributor

auvipy commented Jul 23, 2020

Sorry - given current events, and new priorities at work, I'm not going to be able to address your concerns just now @sliverc. I will get back to it though.

hey! can you pick this up again?

@auvipy
Copy link
Contributor

auvipy commented Jul 23, 2020

I will try to handle it if no one got the time. will try to split the PR in smaller chunks

@keyz182
Copy link
Contributor Author

keyz182 commented Jul 23, 2020

Sorry - given current events, and new priorities at work, I'm not going to be able to address your concerns just now @sliverc. I will get back to it though.

hey! can you pick this up again?

@auvipy Sorry, I'm not going to have time for a few months at least unfortunately :(

If you want to take over, I'm happy to give pointers where I can.

@auvipy
Copy link
Contributor

auvipy commented Jul 23, 2020

OK I will take this over and feel free to review.

@n2ygk
Copy link
Contributor

n2ygk commented Jul 29, 2020

I've just had a quick look at current drf master (still pre-3.12) and have noticed a few things that might impact this code if not already dealt with:

  • many private methods are now public (remove the _). The private versions are still there but will raise a warning.
  • DRF now implements components and has a few other changes in get_schema() but it looks like it still has to be fully overridden because of the need to "expand" endpoints for relationship and related views. An idea for a future PR to DRF might be to add a method that can be more cleanly extended.

@n2ygk
Copy link
Contributor

n2ygk commented Aug 3, 2020

FYI - I've got some free time this week so started looking at this, especially w.r.t. changes to upstream DRF and will be pushing a rebase shortly.

@auvipy
Copy link
Contributor

auvipy commented Aug 4, 2020

FYI - I've got some free time this week so started looking at this, especially w.r.t. changes to upstream DRF and will be pushing a rebase shortly.

Thats great! Looking forwarded to it

@n2ygk n2ygk force-pushed the openapi_schema branch 3 times, most recently from 0f05799 to b4c37c1 Compare August 7, 2020 00:25
@n2ygk
Copy link
Contributor

n2ygk commented Aug 7, 2020

working my way backwards from master through earlier versions of DRF to eventually get tox tests to conditionalize as appropriate and otherwise run cleanly.

@n2ygk
Copy link
Contributor

n2ygk commented Aug 7, 2020

See also PR #804 which I've copied the change over here just to keep this moving and cleanly rebaseable.

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #772 into master will increase coverage by 0.10%.
The diff coverage is 98.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #772      +/-   ##
==========================================
+ Coverage   97.77%   97.87%   +0.10%     
==========================================
  Files          58       62       +4     
  Lines        3104     3443     +339     
==========================================
+ Hits         3035     3370     +335     
- Misses         69       73       +4     
Impacted Files Coverage Δ
example/settings/dev.py 100.00% <ø> (ø)
rest_framework_json_api/schemas/openapi.py 98.21% <98.21%> (ø)
example/tests/snapshots/snap_test_openapi.py 100.00% <100.00%> (ø)
example/tests/test_format_keys.py 100.00% <100.00%> (ø)
example/tests/test_openapi.py 100.00% <100.00%> (ø)
example/tests/unit/test_filter_schema_params.py 100.00% <100.00%> (ø)
rest_framework_json_api/django_filters/backends.py 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b192cb0...af5f4ea. Read the comment docs.

@sliverc
Copy link
Member

sliverc commented Aug 19, 2020

I won't have the time right now to closely look at this as in DRF there has been many changes and this is a fairly large PR.

@n2ygk I guess you won't see this as ready though right? As there are quite a few TODOs in the code. And possibly as there are many changes in DRF we should properly also wait till 3.12 is released.

@n2ygk
Copy link
Contributor

n2ygk commented Aug 19, 2020 via email

@n2ygk
Copy link
Contributor

n2ygk commented Aug 21, 2020

This is getting closer to reviewable. I'll do another rebase when I'm ready and will then request your review.

Copy link
Contributor

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

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

Things I still need to do before a final review request:

  • Check on Oliver's remaining open review comments
  • See if SchemaGenerator.schema_init might be included in upstream DRF.
  • Decide what TODOs can be deferred for now vs. must haves.

@sliverc
Copy link
Member

sliverc commented Oct 14, 2020

@n2ygk went through the conversations and marked the once solved which are. Besides the relationship issue there are also some conversations though which you might have overlooked.
When you go to #772 (review) there is a link "7 hidden conversations Load more..." which I assume you did not see?

@n2ygk
Copy link
Contributor

n2ygk commented Oct 15, 2020

@sliverc please hold off on further review until I solve #772 (comment)

@sliverc
Copy link
Member

sliverc commented Oct 23, 2020

@n2ygk Do you think you will get to the open OAS issues in the next few days?

If not once #846 is merged I would be fine if we release 4.0.0 nowish (mainly to support newest DRF version) and postpone this to the next minor version 4.1.0 as it is fully backwards compatible. What do you think?

@n2ygk
Copy link
Contributor

n2ygk commented Oct 23, 2020 via email

@n2ygk
Copy link
Contributor

n2ygk commented Oct 24, 2020

@sliverc Ready for your review.

@sliverc
Copy link
Member

sliverc commented Oct 29, 2020

Thanks for your work on this! This now looks good as a start and can be vetted as it is used more widely.

@keyz182
Copy link
Contributor Author

keyz182 commented Oct 29, 2020

Nice work @n2ygk !

@n2ygk
Copy link
Contributor

n2ygk commented Oct 29, 2020

@sliverc It looks like travis has stalled.

@n2ygk
Copy link
Contributor

n2ygk commented Oct 29, 2020

@sliverc It looks like travis has stalled.

Not stalled but running really slowly. So far 3+ hours in and not done yet.

@n2ygk
Copy link
Contributor

n2ygk commented Oct 29, 2020

@sliverc It looks like travis has stalled.

Not stalled but running really slowly. So far 3+ hours in and not done yet.

Hmm, this tweet says something about .org vs. .com

@sliverc sliverc merged commit 9113ca0 into django-json-api:master Oct 30, 2020
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.

missing DjangoFilterBackend.get_schema_operation_parameters() Support DRF 3.10+ generateschema (OAS 3)
4 participants