Skip to content

test: fix openapi.test.ts to properly test @example tag behaviour #780

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

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

anshchaturvedi
Copy link
Contributor

The test I wrote before didn't test @example behaviour properly, this fixes it.

@anshchaturvedi anshchaturvedi marked this pull request as ready for review June 3, 2024 20:00
@anshchaturvedi anshchaturvedi requested a review from a team as a code owner June 3, 2024 20:00
@@ -2103,6 +2103,7 @@ testCase('route with descriptions, patterns, and examples', ROUTE_WITH_DESCRIPTI
required: true,
schema: {
type: 'object',
example: "{ 'foo': 'bar' }",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is meant to be a JSON string shouldn't it contain escaped double quotes for keys and values instead of single ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inside ROUTE_WITH_DESCRIPTIONS_PATTERNS_EXAMPLES, if I make it any one of

@example '{ "foo": "bar" }' or
@example "{ "foo": "bar" }" or
@example "{ \"foo\": \"bar\" }"

then it doesn't seem to parse the tag properly (it probably has to do with the quotes because it cuts part of example and puts in the description section of the schema instead).

The only way it cooperates is how it is now. It suspect it has something to do with the parseComment function inside comments.ts but that isn't our implementation. Do you have any ideas of how we can work around this? Or maybe just leave it alone 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we probably should refactor that to not use the external comment-parser anyway

Copy link
Contributor

@bitgopatmcl bitgopatmcl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds example tag test case

@bitgopatmcl bitgopatmcl merged commit 99eb5f7 into master Jun 4, 2024
8 checks passed
@bitgopatmcl bitgopatmcl deleted the DX-439-fix-openapi-tests branch June 4, 2024 18:58
Copy link

github-actions bot commented Jun 4, 2024

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Aug 5, 2024

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants