Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add warning to rdme openapi upload for unexpected slugs #1170

Draft
wants to merge 5 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 245 additions & 0 deletions __tests__/commands/openapi/__snapshots__/upload.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rdme openapi upload > flag error handling > should throw if an error if both \`--version\` and \`--useSpecVersion\` flags are passed 1`] = `
{
"error": [Error: The following error occurred:
--version=1.0.0 cannot also be provided when using --useSpecVersion
See more help with --help],
"stderr": "",
"stdout": "",
}
`;

exports[`rdme openapi upload > given that the API definition is a URL > should create a new API definition in ReadMe 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/openapi.json",
},
"stderr": "- Validating the API definition located at https://example.com/openapi.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "🚀 Your API definition (openapi.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a URL > should handle issues fetching from the URL 1`] = `
{
"error": [Error: Unknown file detected.],
"stderr": "- Validating the API definition located at https://example.com/openapi.json...
✖ Validating the API definition located at https://example.com/openapi.json...
",
"stdout": "",
}
`;

exports[`rdme openapi upload > given that the API definition is a URL > should update an existing API definition in ReadMe 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/openapi.json",
},
"stderr": "- Validating the API definition located at https://example.com/openapi.json...
- Updating your API definition to ReadMe...
✔ Updating your API definition to ReadMe... done!
",
"stdout": "🚀 Your API definition (openapi.json) was successfully updated in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the \`--slug\` flag is passed > should handle a slug with a valid but mismatching file extension 1`] = `
{
"error": [Error: Please provide a valid file extension that matches the extension on the file you provided. Must be \`.json\`, \`.yaml\`, or \`.yml\`.],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the \`--slug\` flag is passed > should handle a slug with an invalid file extension 1`] = `
{
"error": [Error: Please provide a valid file extension that matches the extension on the file you provided. Must be \`.json\`, \`.yaml\`, or \`.yml\`.],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the \`--slug\` flag is passed > should use the provided slug (includes file extension) as the filename 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/custom-slug.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (custom-slug.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the \`--slug\` flag is passed > should use the provided slug (no file extension) as the filename 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/custom-slug.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (custom-slug.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the command is being run in a CI environment > should overwrite an existing API definition without asking for confirmation 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Updating your API definition to ReadMe...
✔ Updating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully updated in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the upload status initially is a pending state > should poll the API and handle timeouts 1`] = `
{
"error": [Error: Sorry, this upload timed out. Please try again later.],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the upload status initially is a pending state > should poll the API once and handle a failure state with a 4xx 1`] = `
{
"error": [Error: The ReadMe API responded with an unexpected error. Please try again and if this issue persists, get in touch with us at [email protected].],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the upload status initially is a pending state > should poll the API once and handle an unexpected state with a 2xx 1`] = `
{
"error": [Error: Your API definition upload failed with an unexpected error. Please get in touch with us at [email protected].],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✖ Creating your API definition to ReadMe... uploaded but not yet processed by ReadMe. Polling for completion...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > and the upload status initially is a pending state > should poll the API until the upload is complete 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... uploaded but not yet processed by ReadMe. Polling for completion... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > given that the \`--version\` flag is not set > should default to the \`stable\` version 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/stable/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > given that the \`--version\` flag is not set > should use the version from the spec file if --\`useSpecVersion\` is passed 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.2.3/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > should create a new API definition in ReadMe 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✔ Creating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully created in ReadMe!
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > should handle upload failures 1`] = `
{
"error": [Error: Your API definition upload failed with an unexpected error. Please get in touch with us at [email protected].],
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Creating your API definition to ReadMe...
✖ Creating your API definition to ReadMe...
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
",
}
`;

exports[`rdme openapi upload > given that the API definition is a local file > should update an existing API definition in ReadMe 1`] = `
{
"result": {
"status": "done",
"uri": "/versions/1.0.0/apis/__tests____fixtures__petstore-simple-weird-version.json",
},
"stderr": "- Validating the API definition located at __tests__/__fixtures__/petstore-simple-weird-version.json...
- Updating your API definition to ReadMe...
✔ Updating your API definition to ReadMe... done!
",
"stdout": "The slug of your API Definition will be updated to __tests____fixtures__petstore-simple-weird-version.json to match ReadMe's slug requirements.
🚀 Your API definition (__tests____fixtures__petstore-simple-weird-version.json) was successfully updated in ReadMe!
",
}
`;
Loading
Loading