Repository navigation
fix: preserve existing OpenAPI environment files - #408
Closed
KennyMcSimpson wants to merge 1 commit into
Closed
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
Conversation
chiragjangiir
left a comment
There was a problem hiding this comment.
Great fix for preserving existing .env files during OpenAPI spec imports (#91).
Key strengths:
- Atomic creation: Using
open("x")withFileExistsErrorhandling guarantees atomic file creation without TOCTOU (time-of-check-to-time-of-use) race conditions between existence checks and writes. - Deterministic versioning: Suffixing collision candidates as
{stem}.{number}{suffix}(e.g.api_example_test.2.env) correctly handles multiple servers with identical sanitized domain names (e.g.http://vshttps://). - Readme synchronization: The generated collection README references the actual created filename (
collection.readme), keeping documentation consistent with disk state.
LGTM! Parametrized tests across OpenAPI 3.0.3 and 3.1.0 cover both single and multiple collisions cleanly.
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.
Closes #91
Importing an OpenAPI document writes environment files into the source directory. If a file already exists, including an environment file from an earlier import, the importer currently overwrites its contents. Different server URLs can also collapse to the same generated filename.
Create environment files exclusively and choose a numbered filename when the destination exists. Existing bytes remain intact, and the generated collection README references the filename actually created.
Validation: all six added regression cases fail against the original implementation and pass with this change. The 40 OpenAPI, Postman, and curl import tests pass through the repository Makefile test target. Coverage includes OpenAPI 3.0/3.1, existing
.envand named files, repeated imports, and colliding server names.The full local suite was stopped after 300 seconds in UI snapshot tests. Separate baseline checks reproduce Windows-only timezone (
time.tzset) and POSIX file-mode failures in the original source. The upstream Linux workflow is awaiting maintainer approval.