Skip to content

Preferred way for outputting #702

@hakandilek

Description

@hakandilek

This is probably both a bug report and a question.

Since cyclonedx.output.get_instance() has been removed via #493 the examples for the outputting in the docs are not valid anymore(bug report):

from cyclonedx.output import get_instance, BaseOutput, OutputFormat

outputter: BaseOutput = get_instance(bom=bom, output_format=OutputFormat.JSON)
bom_json: str = outputter.output_as_string()

Here comes the question part:

🅰️ The preferred way (as suggested in the deprecation message) would be using the cyclonedx.output.make_outputter() like this :

from cyclonedx.output import make_outputter, BaseOutput, OutputFormat, SchemaVersion

outputter: BaseOutput = make_outputter(bom=bom, output_format=OutputFormat.JSON, schema_version=SchemaVersion.V1_6)
bom_json: str = outputter.output_as_string()

🅱️ There is also a much simpler way to use the predefined format+schema combined outputs:

from cyclonedx.output.json import JsonV1Dot6

outputter = JsonV1Dot6(bom=bom)
bom_json: str = outputter.output_as_string()

Which one of 🅰️ or 🅱️ would be the preferred way?

If we agree on it, I can create a PR to resolve the bug in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions