cargo-public-api icon indicating copy to clipboard operation
cargo-public-api copied to clipboard

Output JSON?

Open matthiasbeyer opened this issue 1 year ago • 6 comments
trafficstars

I would like to be able to postprocess my API diffs I generate with cargo-public-api. Would it be possible to add a feature so that cargo-public-api can output JSON?

matthiasbeyer avatar Apr 29 '24 12:04 matthiasbeyer

I'd recommend you to use https://docs.rs/public-api/0.33.1/public_api/#diff-two-versions-of-a-public-api I don't see any problems with the binary providing a json output, a bit unsure what the format should be however

Emilgardis avatar Apr 29 '24 15:04 Emilgardis

TIL there is a crate for that! Awesome! I'll investigate and check whether that solves my issue! <3

matthiasbeyer avatar Apr 30 '24 07:04 matthiasbeyer

a bit unsure what the format should be however

For me, something as simple as this would suffice:

{
    "added": ["..."],
    "removed": ["..."],
    "changed": [
        { "from": "...", "to": "..." }
    ]
}

My issue is mainly that I want to format the cargo-public-api output.

matthiasbeyer avatar Apr 30 '24 11:04 matthiasbeyer

Could you explain in more detail what your use case is? I don't have strong objections to a JSON output format either, but I don't want to do it if there are better solutions to your use case/workflow. :)

Enselic avatar May 01 '24 06:05 Enselic

I want to fill a customizable template with that data, and getting the data as json is the least complicated way.

matthiasbeyer avatar May 01 '24 13:05 matthiasbeyer

Well, I'm open to experimentation.

Not sure we need to keep this issue open? Feel free to open a PR with a prototype once you have one.

Enselic avatar May 01 '24 14:05 Enselic

Let's close this issue to keep the issue inbox clean. But we can of course continue discussing (preferably in the PR).

Enselic avatar Jun 20 '24 04:06 Enselic