feat(poc,openapi-compiler): Add basic openapi compiler#34
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR introduces a new Go application in ChangesOpenAPI instruction compiler and CLI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
83484fd to
b2d2efb
Compare
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.run/poc_openapi run.run.xml:
- Line 19: The run configuration's filePath attribute currently points at the
old curl entrypoint ("poc/curl/main.go") and must be updated to the OpenAPI
app's entrypoint; locate the XML run config element with the filePath attribute
and replace its value ("$PROJECT_DIR$/poc/curl/main.go") with the correct
OpenAPI entrypoint path (e.g. the OpenAPI app main.go) so the run configuration
launches the new app.
In `@poc/openapi/cmd/cmd.go`:
- Around line 32-46: The CLI metadata (Name, Usage, UsageText, Description)
currently brands the tool as "op-to-curl" and mentions "curl client" which is
misleading because the command actually compiles OpenAPI specs; update these
fields (Name, Usage, UsageText and the multi-line Description string) to reflect
OpenAPI output: rename the command to something like "op-to-openapi" or
"op-to-oas", change all occurrences of "curl client" to "OpenAPI spec" (or
"OpenAPI/ OAS output"), and adjust example/help text so examples and flags
describe generating an OpenAPI spec file rather than a curl client. Ensure the
UsageText and Description still convey input options (--input, --input-stdin,
--output) and the expected OP traits.
- Around line 72-99: Detect and reject when both instructionStdin and
instruction are set instead of silently preferring stdin: inside the Action
function before reading stdin or the file (the block that branches on
instructionStdin / instruction / else), add a guard like if instructionStdin &&
instruction != "" { return fmt.Errorf("%w: --input and --input-stdin cannot be
used together", ErrConflictingInputFlags) } (create a new sentinel error
ErrConflictingInputFlags if one does not exist) so the CLI returns a clear error
when both flags are provided.
In `@poc/openapi/internal/compile/compiler.go`:
- Around line 73-90: The ResponseOrRef entries created in the loop lack the
required description field and produce invalid OpenAPI output; update the code
that builds the responses map (the loop iterating opOperation.Error that uses
oputil.PullTermByID(ophttp.StatusID, term.Trait) and assigns
responses[fmt.Sprintf("%s", httpStatusTerm.Value)] = openapi3.ResponseOrRef{})
to populate each ResponseOrRef with at least a description (for example using
the status code and/or httpStatusTerm.Value or a default text) before passing
the map to oa3Operation.Responses.WithMapOfResponseOrRefValues.
In `@poc/openapi/pkg/oputil/decoder.go`:
- Around line 27-39: The YAML fallback path may leave partial data in the target
variable 'ins' which then contaminates the subsequent JSON decode; before
calling json.Unmarshal you must reset 'ins' to its zero value (reinitialize the
struct or slice/map as appropriate) so the JSON decode does not reuse stale
fields. Locate the yaml.Unmarshal/json.Unmarshal calls and insert a
reinitialization of 'ins' (e.g., ins = <zero value of ins's type>) between the
two unmarshal attempts, preserving the existing error accumulation into 'errs'.
In `@poc/openapi/Taskfile.yaml`:
- Line 24: Replace the plain curl invocation "curl
http://localhost:8080/op/instruction > cache/instruction.yaml" with a hardened
invocation that fails fast and doesn't write non-2xx responses: use curl --fail
--show-error --max-time 10 --retry 2 -o cache/instruction.yaml (or write to a
temp file and move into place on success) so transient hangs/timeouts and
non-200 responses cause a non-zero exit and prevent corrupt
cache/instruction.yaml.
- Line 12: Taskfile.yaml currently runs the build command "cmd: go build -o
./build/op-to-curl" which fails if the ./build directory doesn't exist; update
the Taskfile.yaml task that contains this cmd to ensure the output directory is
created first (e.g., run a mkdir -p ./build or equivalent step before invoking
go build) so the directory exists when "go build -o ./build/op-to-curl" runs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 542a105d-313f-433a-9fb9-5e705971197f
⛔ Files ignored due to path filters (1)
poc/openapi/go.sumis excluded by!**/*.sum
📒 Files selected for processing (12)
.run/poc_openapi run.run.xmlpoc/openapi/.gitignorepoc/openapi/.golangci.yamlpoc/openapi/Taskfile.yamlpoc/openapi/cmd/cmd.gopoc/openapi/go.modpoc/openapi/internal/compile/compiler.gopoc/openapi/main.gopoc/openapi/output/.gitignorepoc/openapi/pkg/oputil/decoder.gopoc/openapi/pkg/oputil/pull.gopoc/openapi/pkg/stdin/read.go
53fdf02 to
7d38f43
Compare
7d38f43 to
c538f72
Compare
No description provided.