Skip to content

Support rendering OpenAPI spec#36449

Merged
wxiaoguang merged 4 commits into
go-gitea:mainfrom
wxiaoguang:refactor-render
Jan 26, 2026
Merged

Support rendering OpenAPI spec#36449
wxiaoguang merged 4 commits into
go-gitea:mainfrom
wxiaoguang:refactor-render

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang commented Jan 25, 2026

Fix #20852

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 25, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor Author

image

@wxiaoguang wxiaoguang added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 25, 2026
@wxiaoguang wxiaoguang force-pushed the refactor-render branch 3 times, most recently from c567c00 to 830af2f Compare January 25, 2026 06:03
@wxiaoguang wxiaoguang requested a review from Copilot January 25, 2026 06:04
@wxiaoguang wxiaoguang changed the title Refactor render and support rendering OpenAPI spec Support rendering OpenAPI spec Jan 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the markup rendering system to use file name patterns instead of simple extensions, and adds support for rendering OpenAPI/Swagger specification files using swagger-ui.

Changes:

  • Refactored renderer interface to use FileNamePatterns() instead of Extensions() for more flexible file matching (supports patterns like *.yaml and exact names like openapi.yaml)
  • Added OpenAPI renderer that embeds swagger-ui to display OpenAPI/Swagger specs in YAML or JSON format
  • Updated all renderer implementations and detection logic to use the new pattern-based approach

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
modules/markup/external/openapi.go New OpenAPI renderer implementation with swagger-ui integration
modules/markup/renderer.go Refactored renderer detection to support file name patterns
modules/markup/render.go Updated render context detection methods
web_src/js/standalone/swagger.ts Enhanced to support inline spec content and YAML parsing
web_src/css/standalone/swagger.css Hides embedded spec content textarea
modules/setting/markup.go Updated configuration to use file patterns instead of extensions
modules/markup/*/[renderers] Updated all built-in renderers to use FileNamePatterns()
routers/web/repo/*.go Updated file view routes to use new detection methods
package.json Added js-yaml dependency for YAML parsing
tests/integration/markup_external_test.go Updated tests for renamed functions
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wxiaoguang wxiaoguang force-pushed the refactor-render branch 5 times, most recently from a4eb3f0 to ffb6b57 Compare January 25, 2026 07:14
Comment thread routers/web/repo/view.go Outdated
@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 Jan 25, 2026
@silverwind
Copy link
Copy Markdown
Member

I tried swapping the yaml module to https://github.com/eemeli/yaml, but it resulted in a 300kB larger bundle size, so js-yaml is still superior. Maybe once the yaml module releases v3, it will become superior.

Copy link
Copy Markdown
Member

@silverwind silverwind left a comment

Choose a reason for hiding this comment

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

Tested it, works well.

@GiteaBot GiteaBot removed the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jan 26, 2026
@GiteaBot GiteaBot added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Jan 26, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) January 26, 2026 01:19
@wxiaoguang wxiaoguang marked this pull request as draft January 26, 2026 01:24
auto-merge was automatically disabled January 26, 2026 01:24

Pull request was converted to draft

@wxiaoguang wxiaoguang marked this pull request as ready for review January 26, 2026 01:24
@wxiaoguang wxiaoguang merged commit 4c8f6df into go-gitea:main Jan 26, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Jan 26, 2026
@wxiaoguang wxiaoguang deleted the refactor-render branch January 26, 2026 02:34
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jan 26, 2026
* giteaofficial/main:
  Support rendering OpenAPI spec (go-gitea#36449)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Apr 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI Viewer

5 participants