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

pulpcore with drf-spectacular #785

Merged
merged 1 commit into from Jul 24, 2020
Merged

pulpcore with drf-spectacular #785

merged 1 commit into from Jul 24, 2020

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Jul 10, 2020

Required PR: pulp/pulp_file#413
https://pulp.plan.io/issues/7108
closes #7108

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

fao89 added a commit to fao89/pulp_file that referenced this pull request Jul 10, 2020
@pulpbot
Copy link
Member

pulpbot commented Jul 10, 2020

Attached issue: https://pulp.plan.io/issues/7108

@fao89 fao89 changed the title drf-yasg tp drf-spectacular pulpcore with drf-spectacular Jul 10, 2020
@fao89 fao89 force-pushed the 7108 branch 5 times, most recently from 664674e to 7392564 Compare July 13, 2020 17:29
fao89 added a commit to fao89/pulp_file that referenced this pull request Jul 13, 2020
@fao89 fao89 force-pushed the 7108 branch 5 times, most recently from 0a96276 to 6cff5ed Compare July 14, 2020 15:51
fao89 added a commit to fao89/pulp_file that referenced this pull request Jul 14, 2020
@fao89 fao89 force-pushed the 7108 branch 3 times, most recently from a7a6906 to a6bdfe0 Compare July 14, 2020 21:27
fao89 added a commit to fao89/pulp_file that referenced this pull request Jul 14, 2020
@fao89 fao89 marked this pull request as ready for review July 14, 2020 21:51
Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

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

Great work @fao89 !

.travis/before_install.sh Outdated Show resolved Hide resolved
@@ -86,7 +86,7 @@ def upload_file_in_chunks(file_path)
filechunk.write(chunk)
filechunk.flush()
actual_chunk_size = File.size(filechunk)
response = @uploads_api.update(upload_href, content_range(offset, offset + actual_chunk_size -1, total_size), filechunk)
response = @uploads_api.update(content_range(offset, offset + actual_chunk_size -1, total_size), upload_href, filechunk)
Copy link
Member

Choose a reason for hiding this comment

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

Should we use keyword arguments here?

Copy link
Member Author

@fao89 fao89 Jul 16, 2020

Choose a reason for hiding this comment

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

I tried, but as I don't know ruby, I think I did something wrong and it didn't work

Copy link
Member

Choose a reason for hiding this comment

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

have you tried it like this?

Suggested change
response = @uploads_api.update(content_range(offset, offset + actual_chunk_size -1, total_size), upload_href, filechunk)
response = @uploads_api.update(content_range: content_range(offset, offset + actual_chunk_size -1, total_size), upload_href: upload_href, filechunk: filechunk)

Copy link
Member Author

@fao89 fao89 Jul 17, 2020

Choose a reason for hiding this comment

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

Nope! I tried:

content_range_value = content_range(offset, offset + actual_chunk_size -1, total_size)
response = @uploads_api.update(upload_href: upload_href, content_range: content_range_value, filechunk: filechunk)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Well, if no real rubyist wants to jump in, we should not be blocking on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

The method doesn't accept keyword args:

def update(content_range, upload_href, file, opts = {})
  # ...
end

It would need to be def update(content_range:, upload_href:, file:, opts = {}).

CHANGES/7108.feature Outdated Show resolved Hide resolved
schema_view = get_schema_view(title="Pulp API", permission_classes=[permissions.AllowAny],)
schema_view = get_schema_view(
title="Pulp API", permission_classes=[permissions.AllowAny], generator_class=PulpSchemaGenerator
)

urlpatterns.append(url(r"^{api_root}$".format(api_root=API_ROOT), schema_view))
Copy link
Member

Choose a reason for hiding this comment

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

Do we still want that endpoint there? I think it hides part of the DRF browsable API here.

serializer = force_instance(self.get_request_serializer())
for field_name, field in getattr(serializer, "fields", {}).items():
if isinstance(field, serializers.FileField) and self.method in ("PUT", "PATCH", "POST"):
return ["multipart/form-data", "application/x-www-form-urlencoded"]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe not in this PR, but i'd like us to experiment, whether this hack is necessary if we use the DRF content-negotiation properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

the problem with this is python bindings get lost, it just gets the first, so I did it to ensure multipart/form-data will be the first one

Copy link
Member

Choose a reason for hiding this comment

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

I did some research here. Seems like when you want to upload any data, "multipart/form-data" is the only usable one. But as the file field is optional we should maybe supporting "application/json" as the second option.
But, this is probably out of scope for this PR.

@mdellweg
Copy link
Member

From: https://swagger.io/specification/
It is RECOMMENDED that the root OpenAPI document be named: openapi.json or openapi.yaml.

Is it possible to serve the api schema as a static asset that is generated at install time?

@fao89
Copy link
Member Author

fao89 commented Jul 16, 2020

From: https://swagger.io/specification/
It is RECOMMENDED that the root OpenAPI document be named: openapi.json or openapi.yaml.

Is it possible to serve the api schema as a static asset that is generated at install time?

I believe so, but I didn't look at it, but skimming through drf-spectacular code, it seems it has a CLI for it

@fao89 fao89 force-pushed the 7108 branch 5 times, most recently from c2f478a to b34e182 Compare July 17, 2020 19:59
fao89 added a commit to fao89/pulp-2to3-migration that referenced this pull request Jul 22, 2020
fao89 added a commit to fao89/pulp_deb that referenced this pull request Jul 22, 2020
fao89 added a commit to fao89/pulp-2to3-migration that referenced this pull request Jul 22, 2020
mdellweg added a commit to mdellweg/pulp_python that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_gem that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_npm that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_gem that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_python that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_gem that referenced this pull request Jul 23, 2020
mdellweg added a commit to mdellweg/pulp_npm that referenced this pull request Jul 23, 2020
pulpcore/app/settings.py Outdated Show resolved Hide resolved
Replaced drf-yasg with drf-spectacular.
- This updates the api documentation to openapi v3.
- Plugins may require changes.
- Methods signatures for bindings may change.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the plugin writer changelog.

I think we still need a user facing changelog entry too. Probably include that the schema is openapi v3 and this line that the method signatures in the bindings may change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a question, is it possible to have:

CHANGES/7108.removal
CHANGES/plugin_api/7108.removal

because I think it is not possible to have both with .removal, if so, which one should be removal? And the other one? feature?

@dkliban dkliban merged commit 6126111 into pulp:master Jul 24, 2020
fao89 added a commit to fao89/pulp_rpm that referenced this pull request Jul 24, 2020
Required PR: pulp/pulpcore#785
[noissue]
[nocoverage]
fao89 added a commit to fao89/pulp_rpm that referenced this pull request Jul 24, 2020
Required PR: pulp/pulpcore#785
[noissue]
[nocoverage]
@daviddavis
Copy link
Contributor

@dkliban I thought we agreed to wait until Monday?

@daviddavis
Copy link
Contributor

Nevermind. I misunderstood our conversation. Sorry!

mdellweg added a commit to mdellweg/pulp_npm that referenced this pull request Jul 27, 2020
ThikaXer pushed a commit to ATIX-AG/pulp_deb that referenced this pull request Oct 5, 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.

None yet

5 participants