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

UserAPI.userCreateToken doesn't return token #4

Closed
slonopotamus opened this issue Apr 30, 2021 · 19 comments
Closed

UserAPI.userCreateToken doesn't return token #4

slonopotamus opened this issue Apr 30, 2021 · 19 comments

Comments

@slonopotamus
Copy link
Contributor

slonopotamus commented Apr 30, 2021

According to Swagger schema, userCreateToken returns AccessToken: https://github.com/zeripath/java-gitea-api/blob/master/swagger.v1.json#L11452-L11495

But in generated bindings, userCreateToken method is void: https://github.com/zeripath/java-gitea-api/blob/master/src/main/java/io/gitea/api/UserApi.java#L632

@zeripath
Copy link
Owner

Ugh. I'll take a look. I knew that there was something manual I had to do to the swagger JSON.

@zeripath
Copy link
Owner

zeripath commented May 1, 2021

I've uploaded a fixed release 1.14.0 right now - this should work on all 1.14.x versions of Gitea.

I'll pop a PR on to Gitea to fix this more permanently.

@zeripath
Copy link
Owner

zeripath commented May 1, 2021

@zeripath
Copy link
Owner

zeripath commented May 1, 2021

@slonopotamus do you need me to release a fixed 1.13.x?

@slonopotamus
Copy link
Contributor Author

Yes, please, I can't upgrade due to this bug.

@slonopotamus
Copy link
Contributor Author

slonopotamus commented May 1, 2021

Err... If you released 1.14, then it's fine, no need for additional release.

@zeripath
Copy link
Owner

zeripath commented May 1, 2021

Cool. OK 1.14.0 has been released.

@zeripath zeripath closed this as completed May 1, 2021
@slonopotamus
Copy link
Contributor Author

slonopotamus commented Jul 29, 2021

I somewhat forgot about this thing and now tried to upgrade to newer java-gitea-api again.

The problem is: yes, userCreateToken now returns an AccessToken object. But. AccessToken only has name field: https://github.com/zeripath/java-gitea-api/blob/master/src/main/java/io/gitea/model/AccessToken.java#L32-L33 It doesn't have token itself. So while I can create tokens, I have no idea what token was created and thus can't pass it to API.

P.S. Also note that with modern Swagger schema (1.16.0+dev-56-gb9a0e3323 from https://try.gitea.io/swagger.v1.json) userCreateToken again generates with void return type.

@slonopotamus
Copy link
Contributor Author

Note that back in older days, userCreateToken has a working signature: AccessToken userCreateToken(String username, AccessTokenName accessTokenName). It accepted just token name and returned a full object that had sha1 among other fields.

@zeripath
Copy link
Owner

ugh sorry about this!

@zeripath zeripath reopened this Jul 29, 2021
@zeripath
Copy link
Owner

Probably need to reapply a99fa0c each time.

@slonopotamus
Copy link
Contributor Author

Maybe we should report it upstream (Gitea)? I'm not an expert in Swagger, so don't actually understand why it can't properly generate userCreateToken signature.

@zeripath
Copy link
Owner

OK I think this should now be fixed.

In terms of opening an issue in Gitea - I'll just open a PR.

zeripath added a commit to zeripath/gitea that referenced this issue Jul 29, 2021
There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: zeripath/java-gitea-api#4
Signed-off-by: Andrew Thornton <art27@cantab.net>
@slonopotamus
Copy link
Contributor Author

For the record: I successfully managed to update to 1.14.0-1: git-as-svn/git-as-svn#438

@zeripath
Copy link
Owner

Cool I'll close this. Sorry for missing the problem originally.

techknowlogick added a commit to go-gitea/gitea that referenced this issue Aug 1, 2021
There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: zeripath/java-gitea-api#4
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
zeripath added a commit to zeripath/gitea that referenced this issue Aug 1, 2021
Backport go-gitea#16574

There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: zeripath/java-gitea-api#4
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
6543 pushed a commit to go-gitea/gitea that referenced this issue Aug 2, 2021
Backport #16574

There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: zeripath/java-gitea-api#4
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: zeripath/java-gitea-api#4
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@slonopotamus
Copy link
Contributor Author

This is broken again in 1.15.0: https://github.com/bozaro/git-as-svn/runs/3396683858#step:5:60
Do we need to apply newer Swagger schema from Gitea?

@zeripath
Copy link
Owner

Ah. I think this breakage might be because of a slight change of name and a consequent API change rather than the code being broken.

@slonopotamus
Copy link
Contributor Author

slonopotamus commented Aug 23, 2021

Oh, looks like I didn't drink enough coffee yet and though that was the same problem. No worries, class rename is easy to fix.

@zeripath
Copy link
Owner

Sorry for the unannounced breaking change though.

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

No branches or pull requests

2 participants