Correct swagger annotations for enums, status codes, and notification state#37030
Correct swagger annotations for enums, status codes, and notification state#37030wxiaoguang merged 2 commits intogo-gitea:mainfrom
Conversation
… state Add swagger:enum annotations and migrate all enum comments from the deprecated comma-separated format to JSON arrays. Introduce NotifySubjectStateType with open/closed/merged values. Fix delete reaction endpoints to return 204 instead of 200. BREAKING: delete reaction endpoints now return 204 No Content.
|
This change seems good. For the plan (https://github.com/myers/gitea/tree/feat/openapi3-conversion, especially the commit myers@14d2832), I recalled some discussions for this topic: (als cc @TheFox0x7 🙏 ) |
TheFox0x7
left a comment
There was a problem hiding this comment.
+1 from me. I don't see anything wrong with this.
|
As for the v3; I don't mind generating v3 from v2 if you want to send that too. Though I'd rather generate v2 from v3 and get rid of generating spec from comments as - as you can see - it's not accurate at times, there are not examples etc. I won't even suggest writing spec first and generating server from that as I don't want to do it myself :) |
|
For "v3", some questions in my mind:
|
It does
To allow tools that use openapi 3 specs to generate api clients.
Sounds like a breaking change! ;). The v3 spec is generated from the v2 spec.
Yes it is good enough, at least for the one library I tried (see PR description). I have tried Fern for python as well, which correctly created the client, but I didn't get a chance to test it yet.
You can take a peek at it https://github.com/myers/gitea/tree/feat/openapi3-conversion BTW: I 100% recommend going with spec first API, this was just trying to deliver a feature I needed without rocking the boat too much. |
There are still generators that consume v2 only. Though for every language you'll find one that does v3 only so it cuts both ways. I'd drop v2 but we'd have to have native generation first which swagger does not provide
I don't see a way for this here. AFAIK you'd have to rework entire api, plus I very much doubt anyone here wants to write yaml/json instead of go. And sure, you could write spec in go, serialize it to yaml, then generate server. |
|
Maybe we can leave the discussion to the future. By the way, actually our framework has the ability to fully manage the route endpoints, much better than chi (example: Refactor auth middleware #36848) So maybe now it is feasible to do something like huma (or use huma as the base framework and we call it after we have parsed our routes) |
|
By the way, I removed the "breaking" label. I doubt whether there are really many people using "delete reaction endpoint" and would be really affected. To prevent from frightening most unrelated users, I think this PR doesn't need to be marked as "breaking" |
* main: (35 commits) Correct swagger annotations for enums, status codes, and notification state (go-gitea#37030) Update Nix flake (go-gitea#37024) Bump go and python versions in nix flake (go-gitea#37031) Make task list checkboxes clickable in the preview tab (go-gitea#37010) Add support for in_progress event in workflow_run webhook (go-gitea#36979) Fix various problems (go-gitea#37029) Update AI Contribution Policy (go-gitea#37022) Migrate from webpack to vite (go-gitea#37002) Upgrade yaml (go-gitea#37015) Fix issue label deletion with Actions tokens (go-gitea#37013) Hide delete branch or tag buttons in mirror or archived repositories. (go-gitea#37006) Update AGENTS.md with additional guidelines (go-gitea#37018) Optimize 'refreshAccesses' to perform update without removing then adding (go-gitea#35702) Fix relative-time RangeError (go-gitea#37021) Restyle Workflow Graph (go-gitea#36912) Update message severity colors, fix navbar double border (go-gitea#37019) Clean up checkbox cursor styles (go-gitea#37016) add missing cron tasks to example ini (go-gitea#37012) Add e2e tests for server push events (go-gitea#36879) Update JS dependencies (go-gitea#37001) ...
* origin/main: (69 commits) Correct swagger annotations for enums, status codes, and notification state (go-gitea#37030) Update Nix flake (go-gitea#37024) Bump go and python versions in nix flake (go-gitea#37031) Make task list checkboxes clickable in the preview tab (go-gitea#37010) Add support for in_progress event in workflow_run webhook (go-gitea#36979) Fix various problems (go-gitea#37029) Update AI Contribution Policy (go-gitea#37022) Migrate from webpack to vite (go-gitea#37002) Upgrade yaml (go-gitea#37015) Fix issue label deletion with Actions tokens (go-gitea#37013) Hide delete branch or tag buttons in mirror or archived repositories. (go-gitea#37006) Update AGENTS.md with additional guidelines (go-gitea#37018) Optimize 'refreshAccesses' to perform update without removing then adding (go-gitea#35702) Fix relative-time RangeError (go-gitea#37021) Restyle Workflow Graph (go-gitea#36912) Update message severity colors, fix navbar double border (go-gitea#37019) Clean up checkbox cursor styles (go-gitea#37016) add missing cron tasks to example ini (go-gitea#37012) Add e2e tests for server push events (go-gitea#36879) Update JS dependencies (go-gitea#37001) ... # Conflicts: # package.json # pnpm-lock.yaml # tests/e2e/utils.ts # web_src/css/themes/theme-gitea-dark.css # web_src/css/themes/theme-gitea-light.css # web_src/js/bootstrap.ts # web_src/js/features/codeeditor.ts # web_src/js/modules/errors.test.ts # webpack.config.ts
Summary
Add swagger:enum annotations and migrate all enum comments from the deprecated comma-separated format to JSON arrays. Introduce NotifySubjectStateType with open/closed/merged values. Fix delete reaction endpoints to return 204 instead of 200.
This is one part of a stacked set. The other adds a OpenAPI 3 spec generated off of the swagger spec. With these corrections it is good enough to have OpenAPI 3 code generating tools (like rust's https://github.com/oxidecomputer/progenitor) to create API clients based off of it.
This was built in Claude Code, with human review.