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
Conversation
Required PR: pulp/pulpcore#785 [noissue]
|
Attached issue: https://pulp.plan.io/issues/7108 |
664674e
to
7392564
Compare
Required PR: pulp/pulpcore#785 [noissue]
0a96276
to
6cff5ed
Compare
Required PR: pulp/pulpcore#785 [noissue]
a7a6906
to
a6bdfe0
Compare
Required PR: pulp/pulpcore#785 [noissue]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @fao89 !
| @@ -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) | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
| 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) |
There was a problem hiding this comment.
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)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = {})
# ...
endIt would need to be def update(content_range:, upload_href:, file:, opts = {}).
| 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)) |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
From: https://swagger.io/specification/ 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 |
c2f478a
to
b34e182
Compare
Required PR: pulp/pulpcore#785 Required PR: pulp/pulp_file#413 Required PR: pulp/pulp_rpm#1779 Required PR: pulp/pulp_container#128 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 Required PR: pulp/pulp_file#413 Required PR: pulp/pulp_rpm#1779 Required PR: pulp/pulp_container#128 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
| Replaced drf-yasg with drf-spectacular. | ||
| - This updates the api documentation to openapi v3. | ||
| - Plugins may require changes. | ||
| - Methods signatures for bindings may change. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Required PR: pulp/pulp_file#413 https://pulp.plan.io/issues/7108 closes #7108
Required PR: pulp/pulpcore#785 [noissue] [nocoverage]
Required PR: pulp/pulpcore#785 [noissue] [nocoverage]
|
@dkliban I thought we agreed to wait until Monday? |
|
Nevermind. I misunderstood our conversation. Sorry! |
Required PR: pulp/pulpcore#785 [noissue]
Required PR: pulp/pulpcore#785 [noissue]
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