Skip to content

feat: support array examples at arbitrary levels #853

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 2 commits into from
Jul 29, 2024
Merged

feat: support array examples at arbitrary levels #853

merged 2 commits into from
Jul 29, 2024

Conversation

ad-world
Copy link
Contributor

@ad-world ad-world commented Jul 29, 2024

DX-622

This PR removes support for the @arrayExample jsdoc, and extends the functionality of the @example tag so that it can be used with arrays to show array example and non-array examples as well.

This is how to use the new functionality.

Case 1.
Want to show an example of an item within the array

/**
@example exampleItem
*/
field: t.array(t.string)

This will render as this:

{
    type: 'array',
    items: {
        type: 'string',
        example: 'exampleItem'
    }
}

Case 2. Want to render an array example

/**
@example ["exampleItem1", "exampleItem2"]
*/
field: t.array(t.string)

This is how it would render:

{
    type: 'array',
    example: ['exampleItem1', 'exampleItem2']
    items: {
        type: 'string'    
    }
}

Case 3. Want to render an item + array example

/**
@example btc
*/
const coinString = t.string

... 
/** 
@example ["btc", "eth"]
field: t.array(coinString)
*/

This is how it would render:

{
    type: 'array',
    example: ['btc', 'eth']
    items: {
        type: 'string',
        example: 'btc'
    }
}

@ad-world ad-world self-assigned this Jul 29, 2024
@ad-world ad-world marked this pull request as ready for review July 29, 2024 17:42
@ad-world ad-world requested review from a team as code owners July 29, 2024 17:42
@ericcrosson-bitgo ericcrosson-bitgo self-assigned this Jul 29, 2024
Copy link
Contributor

@ericcrosson-bitgo ericcrosson-bitgo left a comment

Choose a reason for hiding this comment

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

Test cases look good.

What is your plan regarding call-sites that are using arrayExample today?

Please add the missing semicolon that the linter flagged and once we have a solid roll-out plan, this looks good to merge

@ad-world
Copy link
Contributor Author

ad-world commented Jul 29, 2024

What is your plan regarding call-sites that are using arrayExample today?

First step is to update all @arrayExample's in WPT to just use @example. There are only 2, so it is a trivial task.
Next step is to generate WPT docs locally (with this update and check diffs with current wallet-platform.yaml. Nothing should change.
Next step is to bump openapi-generator in dev-portal (after this is merged), so that the changes are put into effect

@ad-world
Copy link
Contributor Author

Copy link
Contributor

@ericcrosson-bitgo ericcrosson-bitgo left a comment

Choose a reason for hiding this comment

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

Seems fine to not consider this a breaking change since the removed arrayExample tag is undocumented and was recently added -- so adoption is expected to be minimal.

Approving but not merging yet so you can coordinate this with your other PRs

@ad-world ad-world merged commit 77ad820 into master Jul 29, 2024
6 checks passed
@ad-world ad-world deleted the DX-622 branch July 29, 2024 20:29
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 📦🚀

@ad-world ad-world restored the DX-622 branch July 29, 2024 20:42
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 📦🚀

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 📦🚀

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 📦🚀

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