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

Add return type to GetRawFileOrLFS and GetRawFile #31680

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

AdamMajer
Copy link
Contributor

Document return type for the endpoints that fetch specific files from a repository. This allows the swagger generated code to read the returned data.

Document return type for the endpoints that fetch specific files
from a repository. This allows the swagger generated code to
read the returned data.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 23, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 23, 2024
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Jul 23, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 23, 2024
@AdamMajer AdamMajer marked this pull request as draft July 24, 2024 12:19
@AdamMajer
Copy link
Contributor Author

While the interface is now working and getting the file content, I seem to be getting an error

... is not supported by the TextConsumer, can be resolved by supporting TextUnmarshaler interface"}

I'll convert this to draft as I investigate the cause.

@AdamMajer AdamMajer marked this pull request as ready for review July 24, 2024 15:49
@AdamMajer
Copy link
Contributor Author

AdamMajer commented Jul 24, 2024

I've found a potential issue here. Not with the fix but what it entails. Currently, the swagger generated code doesn't have ability to consume the Body since it's not parsed. By adding the return type to file, it's possible to pass the writer that then can consume the Body.

Swagger generated code uses returned mime-type to determine the type of consumer it allocates. So for text/plain mime, it allocates TextConsumer. Then this complains as above unless there is a trivial TextUnmarshaller() . This means that it may be possible to fix these weird issues by hardcoding "application/octet-stream" as the file type instead of trying to detect it in the Gitea's GetRawFile() endpoints. I'll try that tomorrow.

TL;DR: bugs everywhere and not in Gitea 😄

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 24, 2024
@silverwind
Copy link
Member

@AdamMajer If you want to wait with merging, please put PR into draft status :)

@AdamMajer
Copy link
Contributor Author

It's OK to get this merged. The other problem here is with go-swagger and mime-type combinations. It should be addressed elsewhere.

@wolfogre wolfogre added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 25, 2024
@silverwind silverwind merged commit bae87df into go-gitea:main Jul 25, 2024
26 checks passed
@GiteaBot GiteaBot added this to the 1.23.0 milestone Jul 25, 2024
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 25, 2024
@AdamMajer AdamMajer deleted the fix-swagger branch July 25, 2024 12:09
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 29, 2024
* giteaofficial/main:
  Make GetRepositoryByName more safer (go-gitea#31712)
  [skip ci] Updated licenses and gitignores
  Run `go-install` in `deps-tools` in parallel (go-gitea#31711)
  Hide the "Details" link of commit status when the user cannot access actions (go-gitea#30156)
  Enable `no-jquery/no-parse-html-literal` and fix violation (go-gitea#31684)
  [skip ci] Updated translations via Crowdin
  OIDC: case-insensitive comparison for auth scheme `Basic` (go-gitea#31706)
  Support `pull_request_target` event for commit status (go-gitea#31703)
  Add types to fetch,toast,bootstrap,svg (go-gitea#31627)
  Run `detectWebAuthnSupport` only if necessary (go-gitea#31691)
  add `username` to OIDC introspection response (go-gitea#31688)
  Add return type to GetRawFileOrLFS and GetRawFile (go-gitea#31680)
  Support delete user email in admin panel (go-gitea#31690)
  Use GetDisplayName() instead of DisplayName() to generate rss feeds (go-gitea#31687)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants