Skip to content

go-swagger mixin outputs json with the --format=yaml option #2817

@au-phiware

Description

@au-phiware

Problem statement

go-swagger mixin outputs json with the --format=yaml option.

Steps to reproduce

From the root of this repo the following is expected to generate (nicely formatted) YAML:

go run github.com/go-swagger/go-swagger/cmd/swagger@v0.30.0 mixin --format=yaml --output /dev/stdout examples/authentication/swagger.yml examples/stream-server/swagger.yml

Instead the following is outputted:

2022/08/30 12:06:59 args[0] = examples/authentication/swagger.yml
2022/08/30 12:06:59 args[1:] = [examples/stream-server/swagger.yml]
{"consumes": ["application/keyauth.api.v1+json", "application/json"], "produces": ["application/keyauth.api.v1+json", "application/json"], "schemes": ["http"], "swagger": "2.0", "info": {"description": "Example server for emitting newline delimited JSON", "title": "keyauth debug", "version": "0.3.0"}, "basePath": "/api", "paths": {"/customers": {"get": {"tags": ["customers"], "summary": "Get a customerId given an SSN", "operationId": "getId", "parameters": [{"name": "info", "in": "body", "schema": {"$ref": "#/definitions/social_id"}}], "responses": {"200": {"description": "OK", "schema": {"$ref": "#/definitions/customer"}}, "401": {"description": "unauthorized", "schema": {"$ref": "#/definitions/error"}}, "404": {"description": "resource not found", "schema": {"$ref": "#/definitions/error"}}, "default": {"description": "error", "schema": {"$ref": "#/definitions/error"}}}}, "post": {"tags": ["customers"], "summary": "Create a new customer to track", "operationId": "create", "parameters": [{"name": "info", "in": "body", "schema": {"$ref": "#/definitions/customer"}}], "responses": {"201": {"description": "created", "schema": {"$ref": "#/definitions/customer"}}, "default": {"description": "error", "schema": {"$ref": "#/definitions/error"}}}}}, "/elapse/{length}": {"get": {"description": "Count down the seconds remaining", "summary": "Count down the number of seconds", "operationId": "elapse", "parameters": [{"maximum": 30, "minimum": 2, "type": "integer", "description": "How many seconds to count down", "name": "length", "in": "path", "required": true}], "responses": {"200": {"description": "Secondly update on remaining time", "schema": {"type": "string", "format": "binary"}}, "403": {"description": "Contrived - thrown when length of 11 is chosen"}}}}}, "definitions": {"Mark": {"type": "object", "required": ["remains"], "properties": {"remains": {"type": "integer"}}}, "customer": {"type": "object", "required": ["customerId", "name", "surname", "ssn", "fipsCode"], "properties": {"agentId": {"description": "agent associated with this customer", "type": "integer", "format": "int32"}, "customerId": {"description": "internal identifier of a customer", "type": "integer", "format": "int64", "readOnly": true}, "fipsCode": {"type": "string", "format": "string", "minLength": 1}, "name": {"type": "string", "format": "string", "minLength": 1}, "ssn": {"description": "Lookup identifier to find a customer in the system", "type": "string", "format": "string", "minLength": 11}, "surname": {"type": "string", "format": "string", "minLength": 1}}}, "error": {"type": "object", "required": ["message"], "properties": {"code": {"type": "integer", "format": "int64"}, "fields": {"type": "string"}, "message": {"type": "string"}}}, "principal": {"type": "string"}, "social_id": {"type": "object", "required": ["ssn"], "properties": {"ssn": {"type": "string", "format": "string", "minLength": 11}}}}, "securityDefinitions": {"key": {"type": "apiKey", "name": "x-token", "in": "header"}}, "security": [{"key": []}]}

Strictly speaking it is YAML, but not the YAML that was expected 😆

Environment

swagger version: 0.30.0
go version: 1.17.10
OS: linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions