Skip to content

Problem with generate server #2634

@MarcSky

Description

@MarcSky

Problem statement

I want to generate my swagger spec with using go-swagger 0.27.0 but I got error:

The swagger spec at  is invalid against swagger specification 2.0. see errors :
- some references could not be resolved in spec. First found: invalid character 's' looking for beginning of value

When I used go-swagger 0.25.0 Its worked correctly.

Swagger specification

swagger: '2.0'

info:
  title: BACKEND
  version: 0.0.1
schemes:
  - http

consumes:
  - application/json
produces:
  - application/json

paths:
  /health-check:
    get:
      operationId: healthCheck
      description: healthCheck
      responses:
        '200':
          description: 'healthCheck'
          schema:
            $ref: '#/responses/Error'

definitions:
  Error:
    type: object
    required:
      - code
      - description
    properties:
      code:
        type: integer
        format: int32
      description:
        type: string

responses:
  Error:
    description: Error
    schema:
      $ref: "#/definitions/Error"

Steps to reproduce

I using command:
swagger generate server --api-package op --model-package model --strict-responders --strict-additional-properties --keep-spec-order --exclude-main

I found problem is the using - $ref, because when I removing this row my problem is disappears.

Environment

swagger version: 0.27.0
go version: go1.16.7
OS: Latest MacOS

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