Skip to content

swagger flatten randomizes order in yaml output #2850

@chlindell

Description

@chlindell

Problem statement

When running swagger flatten with --format=yaml the order of the output paths seems to be randomized. This does not occur when using --format=json

Swagger specification

https://petstore.swagger.io/v2/swagger.json

Steps to reproduce

Download petstore swagger and save as petstore.json
$GOPATH/bin/swagger flatten --quiet --with-flatten=remove-unused --format=yaml --output=petstore1.yaml petstore.json
$GOPATH/bin/swagger flatten --quiet --with-flatten=remove-unused --format=yaml --output=petstore2.yaml petstore.json
$GOPATH/bin/swagger flatten --quiet --with-flatten=remove-unused --format=json --output=petstore1.json petstore.json
$GOPATH/bin/swagger flatten --quiet --with-flatten=remove-unused --format=json --output=petstore2.json petstore.json

diff petstore1.json petstore2.json
diff petstore1.yaml petstore2.yaml

json files are identical but the yaml files differ a lot. Expectation is to have deterministic order like in the json files.

Environment

swagger version: 0.30.3
go version: 1.17.8
OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions