Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for useful error message on "type:string" #2376

Open
RubenGarcia opened this issue Aug 11, 2020 · 1 comment
Open

Request for useful error message on "type:string" #2376

RubenGarcia opened this issue Aug 11, 2020 · 1 comment
Labels
duplicate validate spec Related to github.com/go-openapi/validate

Comments

@RubenGarcia
Copy link

RubenGarcia commented Aug 11, 2020

Problem statement

if a swagger is missing a space in "type: string" and is written "type:string"
swagger generate server produces "json: cannot unmarshal string into Go struct field SwaggerProps.definitions of type struct { spec.SchemaProps; spec.SwaggerSchemaProps }"
Something like
"Missing space in 'type:string' would be a better error message

Swagger specification

---
swagger: "2.0"
basePath: "/api/v0.1.2"
info:
  title: Test
  description: Test
  version: "0.1"
  contact:
    email: a@b.example.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

definitions:
  Eudat:
    type: object
    properties:
      EUDATFIO:
        type:string 

paths:
  /test:
    get:
      responses:
        '200':
          description: test
          schema:
            $ref: "#/definitions/Eudat"

Steps to reproduce

swagger generate server

Environment

swagger version: v0.25.0
go version: 1.14.2
OS: Ubuntu 18.04.4 LTS

@fredbi fredbi added the validate spec Related to github.com/go-openapi/validate label Aug 11, 2020
@fredbi
Copy link
Contributor

fredbi commented Aug 11, 2020

Yes, the validator first unmarshals the spec and there is no attempt to keep the full context of the unmarshaling error.
This is another instance of old issues #1425 and #1308. Basically, this was the intent with #121, and we never completed it.

This kind of improvement (most likely in go-openapi/validate) would be indeed welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate validate spec Related to github.com/go-openapi/validate
Projects
None yet
Development

No branches or pull requests

2 participants