fix(openapi/upload): better handling for mismatching files/slugs#1345
fix(openapi/upload): better handling for mismatching files/slugs#1345kanadgupta merged 13 commits intonextfrom
Conversation
it almost always will, but just in case!
emilyskuo
left a comment
There was a problem hiding this comment.
One clarifying question and one minor copy tweak, but otherwise looks good!
| filename = | ||
| // biome-ignore lint/nursery/noUnnecessaryConditions: false positive | ||
| extensionsMatch && fileExtension | ||
| ? `${this.flags.slug.replace(slugExtension, '')}${fileExtension}` |
There was a problem hiding this comment.
Is this replace only changing the filename in the case where slugExtension is .yml and fileExtension is .yaml (and vice versa)? If extensions match and are .json, the result is the same right?
There was a problem hiding this comment.
the main reason this is here is to account for if someone passes in something like rdme openapi upload some-file.json --slug custom-slug — in this case it would add the .json to the custom-slug prior to upload. but yes, in most cases, the replacement isn't actually changing the slug's file extension!
src/commands/openapi/upload.ts
Outdated
| if (fileExtension !== slugExtension && !(isFileYaml && yamlExtensions.includes(slugExtension))) { | ||
| extensionsMatch = false; | ||
| this.warn( | ||
| `The file extension in your provided slug (${slugExtension}) does not match the file extension of the file you're uploading (${fileExtension}). Your API definition will be uploaded as ${isFileYaml ? 'JSON' : 'YAML'}.`, |
There was a problem hiding this comment.
It's implied, but might be nice to explicitly say that we're converting the file
| `The file extension in your provided slug (${slugExtension}) does not match the file extension of the file you're uploading (${fileExtension}). Your API definition will be uploaded as ${isFileYaml ? 'JSON' : 'YAML'}.`, | |
| `The file extension in your provided slug (${slugExtension}) does not match the file extension of the file you're uploading (${fileExtension}). Your API definition will be converted and uploaded as ${isFileYaml ? 'JSON' : 'YAML'}.`, |
There was a problem hiding this comment.
ah yes agreed 🧠 i went a little further to clean this up, let me know what you think! 83dd203
Co-Authored-By: Emily Kuo <58803587+emilyskuo@users.noreply.github.com>
the diff was a lil confusing, this cleans it up
## [10.5.2-next.2](v10.5.2-next.1...v10.5.2-next.2) (2025-09-17) ### Bug Fixes * **openapi/upload:** better handling for mismatching files/slugs ([#1345](#1345)) ([a16fcae](a16fcae)) [skip ci]
|
🎉 This PR is included in version 10.5.2-next.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 10.5.2 🎉 The release is available on: (Note: Kanad wrote this by hand this because the |
🧰 Changes
we previously had a restriction in place where you could not upload a JSON file (e.g.,
petstore.json) to a slug with a YAML file extension (e.g.,--slug file.yml). the reasoning was that we didn't want to create any unexpected client-side behaviors and we wanted to prioritize explicitness.however, we've been getting feedback that it's misleading how
rdmedirects customers towards certain slugs, only to see an error that they can't use that slug due to this file extension restriction.this PR lifts that restriction and makes it so
rdmewill convert a JSON file to YAML prior to uploading if the slug has a YAML file extension (or vice versa). it will also emit a warning to the user when this happens!🧬 QA & Testing
added a bunch of tests for this behavior!