| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I could see this as a feat or a fix depending on how we want to do it - I don't think too many folks are directly depending on the internals of how it's compressed, and should instead use the generated helper functions to decompress it |
Sorry, something went wrong.
Greptile SummaryThe PR changes embedded OpenAPI specifications from DEFLATE to LZW compression to make generated output more stable across Go releases.
Confidence Score: 4/5The PR should not merge until existing partial user-template overrides have a compatible migration or fallback for the new embedded-spec format. The bundled compressor and decoder agree, but the generator changes the payload contract unconditionally while allowing users to replace the decoder template independently, leaving existing DEFLATE overrides unable to read regenerated specifications. Files Needing Attention: pkg/codegen/inline.go, pkg/codegen/templates/inline.tmpl Important Files Changed
### Issue 1
pkg/codegen/inline.go:74
**Custom decoders receive incompatible payloads**
When a user overrides only `inline.tmpl` with the previous DEFLATE decoder, `compressSpec` now supplies LZW bytes to that decoder, causing the generated `GetSpec` and `GetSwagger` APIs to fail to load the embedded OpenAPI document. This payload-format change needs a compatibility path for independently overridden templates.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(codegen): migrate embedded spec com..." | Re-trigger Greptile |
Sorry, something went wrong.
| // embedded spec. | ||
| func compressSpec(data []byte) (string, error) { | ||
| var buf bytes.Buffer | ||
| zw := lzw.NewWriter(&buf, lzw.LSB, 8) |
There was a problem hiding this comment.
Custom decoders receive incompatible payloads
When a user overrides only inline.tmpl with the previous DEFLATE decoder, compressSpec now supplies LZW bytes to that decoder, causing the generated GetSpec and GetSwagger APIs to fail to load the embedded OpenAPI document. This payload-format change needs a compatibility path for independently overridden templates.
Knowledge Base Used:
Prompt To Fix With AIThis is a comment left during a code review.
Path: pkg/codegen/inline.go
Line: 74
Comment:
**Custom decoders receive incompatible payloads**
When a user overrides only `inline.tmpl` with the previous DEFLATE decoder, `compressSpec` now supplies LZW bytes to that decoder, causing the generated `GetSpec` and `GetSwagger` APIs to fail to load the embedded OpenAPI document. This payload-format change needs a compatibility path for independently overridden templates.
**Knowledge Base Used:**
- [Codegen Pipeline](https://app.greptile.com/oapi-codegen/-/custom-context/knowledge-base/oapi-codegen/oapi-codegen/-/docs/codegen-pipeline.md)
- [Server & Client Templates (pkg/codegen/templates)](https://app.greptile.com/oapi-codegen/-/custom-context/knowledge-base/oapi-codegen/oapi-codegen/-/docs/templates-codegen.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Sorry, something went wrong.
…dSpec` When we embed the OpenAPI spec as an "embedded spec" in the generated code, we compress its JSON form (with `compress/flate`) and then Base64-encode the output. While upgrading to Go 1.27, #2536 noticed that there is now a diff in the generated code, due to a slight compression improvement in `compress/flate`, which means that any Go 1.27 users will now see a diff. To provide a more stable output across Go versions, we can change our compression algorithm. Before we do this, we can extract a `compressSpec` helper function and add a test to cover the existing compression, which will fail on Go 1.27. Co-Authored-By: Claude Sonnet 5 <claude-code@jamietanna.co.uk>
When we embed the OpenAPI spec as an "embedded spec" in the generated code, we compress its JSON form (with `compress/flate`) and then Base64-encode the output. While upgrading to Go 1.27, #2536 noticed that there is now a diff in the generated code, due to a slight compression improvement in `compress/flate`, which means that any Go 1.27 users will now see a diff. To provide a more stable output across Go versions, we can change our compression algorithm. Through testing, `compress/lzw` appears to be stable across Go 1.26 and Go 1.27, so we can switch this over. Closes #2536. Co-Authored-By: Claude Sonnet 5 <claude-code@jamietanna.co.uk>
| Back | FazBrowse Home | New Git URL |
refactor(codegen): extract compressSpec helper from GenerateInlinedSpec
When we embed the OpenAPI spec as an "embedded spec" in the generated
code, we compress its JSON form (with compress/flate) and then
Base64-encode the output.
While upgrading to Go 1.27, Go 1.27 produces different answer for the embedded spec #2536 noticed that there is now a diff in
the generated code, due to a slight compression improvement in
compress/flate, which means that any Go 1.27 users will now see a
diff.
To provide a more stable output across Go versions, we can change our
compression algorithm.
Before we do this, we can extract a compressSpec helper function and
add a test to cover the existing compression, which will fail on Go
1.27.
feat(codegen): migrate embedded spec compression to compress/lzw
When we embed the OpenAPI spec as an "embedded spec" in the generated
code, we compress its JSON form (with compress/flate) and then
Base64-encode the output.
While upgrading to Go 1.27, Go 1.27 produces different answer for the embedded spec #2536 noticed that there is now a diff in
the generated code, due to a slight compression improvement in
compress/flate, which means that any Go 1.27 users will now see a
diff.
To provide a more stable output across Go versions, we can change our
compression algorithm.
Through testing, compress/lzw appears to be stable across Go 1.26 and
Go 1.27, so we can switch this over.
Closes Go 1.27 produces different answer for the embedded spec #2536.