Fix vertical misalignment between input and output panels#1
Merged
Conversation
…gger 2.0 conversion Co-authored-by: c6-dev <31777460+c6-dev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add static web page for OpenAPI conversion in browser
Add WebAssembly browser build and static web UI for in-browser OpenAPI 3.0 → Swagger 2.0 conversion
Mar 16, 2026
Co-authored-by: c6-dev <31777460+c6-dev@users.noreply.github.com>
Copilot
AI
changed the title
Add WebAssembly browser build and static web UI for in-browser OpenAPI 3.0 → Swagger 2.0 conversion
Add Emscripten/Wasm browser build and GitHub Actions CI/CD
Mar 16, 2026
Co-authored-by: c6-dev <31777460+c6-dev@users.noreply.github.com>
Copilot
AI
changed the title
Add Emscripten/Wasm browser build and GitHub Actions CI/CD
Fix vertical misalignment between input and output panels
Mar 16, 2026
c6-dev
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The input panel's textarea started lower than the output panel's because the "Upload file" button occupied a dedicated row between the label and textarea, while the output panel went straight from label to textarea.
Changes —
wasm/index.html.panel-headerflex row (space-between) used by both panels — label on the left, optional action on the right.panel-headeralongside the label, eliminating the dedicated button row that caused the offsetmin-height: calc(0.85rem * 1.2 + 1rem)on.panel-headerensures the output panel's text-only header matches the button height exactly, so both textareas start at the same vertical positionOriginal prompt
Goal
Add a static web page that runs the OpenAPI 3.0 → Swagger 2.0 conversion entirely in the browser using WebAssembly (Emscripten). This allows the tool to be hosted on GitHub Pages or any static file host with no server-side component.
Background
The project is currently a C++ CLI tool (
openapi-downgrader.exe input.yaml output.yaml) built with Visual Studio 2022. It uses yaml-cpp (headers vendored ininclude/yaml-cpp/, prebuilt libs inlib/). The conversion logic lives in:code/Converter.h/code/Converter.cpp— theConverterclass withConvert(const std::string& source)methodcode/Util.h/code/Util.cpp— utility functions (URL parsing, ref fixing, etc.)code/openapi-downgrader.cpp— CLI entry point (main())The key blocker for running in a browser is that
Converter::Convert()callsYAML::LoadFile(source)which reads from the filesystem. This needs to be changed toYAML::Load(source)to accept a raw YAML string instead.Required Changes
1. Refactor
Converterto support string input (non-breaking)In
code/Converter.cpp, add a new method (or modify the existing one) so the converter can accept raw YAML content as a string rather than a file path. The existing CLI behavior must still work. The cleanest approach:std::string ConvertString(const std::string& yamlContent)to theConverterclass that usesYAML::Load(yamlContent)instead ofYAML::LoadFile(source).Convert(file path) andConvertString(raw string) share the same conversion pipeline, just differing in how the YAML is initially loaded.code/Converter.hto declare the new method.2. Create Emscripten/WebAssembly entry point
Create a new file
wasm/wasm_entry.cppthat:Converter.h<emscripten/bind.h>(Embind)convert(std::string yamlInput) -> std::stringthat creates aConverterinstance, callsConvertString(yamlInput), and returns the result.EMSCRIPTEN_BINDINGSto export theconvertfunction to JavaScript.3. Create the static web UI
Create
wasm/index.html— a single self-contained HTML file with embedded CSS and JavaScript that provides:<input type="file" accept=".yaml,.yml,.json">) as an alternative to pastingconvert()function.yamlfile (using Blob + URL.createObjectURL)The HTML file should load the Emscripten-generated JS glue (
downgrader.js) and useModule.onRuntimeInitializedor the Embind API to know when the Wasm is ready.4. Create a CMakeLists.txt for the Emscripten build
Create
wasm/CMakeLists.txt(or aMakefile) that:code/Converter.cpp,code/Util.cpp,wasm/wasm_entry.cppand the yaml-cpp source files withem++include/directory for yaml-cpp headers--bind) and appropriate flags (-O2,-s WASM=1,-s ALLOW_MEMORY_GROWTH=1,-s MODULARIZE=1,-s EXPORT_NAME='createModule')downgrader.jsanddowngrader.wasminto awasm/dist/orwasm/output directoryImportant note about yaml-cpp sources: The repository only has yaml-cpp headers vendored in
include/yaml-cpp/and prebuilt static libraries inlib/. The Emscripten build cannot use the prebuilt Windows.libfiles. The build system needs to either:FetchContent) and compile them from source with Emscripten, ORThe recommended approach is using CMake
FetchContentto download yaml-cpp at configure time.5. Add build instructions
Create
wasm/README.mdwith:python3 -m http.serveror similar)6. Update the root README.md
Add a "Web Version" section to the existing
README.mdthat:wasm/directory for build instructionsImportant Constraints
.sln/.vcxproj) must NOT be broken.include/yaml-cpp/. The Wasm build should use these same headers for consistency but needs to compile yaml-cpp from...This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.