Giter Club home page Giter Club logo

Comments (5)

kailuowang avatar kailuowang commented on May 26, 2024

Thanks for reporting these errors. I was aware of them but since they don't affect the final swagger UI result I forgot to log them. The issue is that in our code, we use the same model to represent both fields in schemas and fields in endpoints, but the json representation of required field is different in these two types of fields. Our code ended up producing json for both format, which can certainly be improved.

from play-swagger.

Driox avatar Driox commented on May 26, 2024

Thanks for the quick answer

It don't affect the swagger UI but the validation badge will be in error and that may be harmful for a public API.

from play-swagger.

metasim avatar metasim commented on May 26, 2024

I'm getting validation errors too, which is a concern as I plan on generating cross-language bindings against the API, and anything out of spec is a liability.

Example error from swagger-validator:

{
  "schemaValidationMessages": [
    {
      "level": "error",
      "domain": "validation",
      "keyword": "type",
      "message": "instance type (boolean) does not match any allowed primitive type (allowed: [\"array\"])",
      "schema": {
        "loadingURI": "http://json-schema.org/draft-04/schema#",
        "pointer": "/definitions/stringArray"
      },
      "instance": {
        "pointer": "/definitions/foo.bar.baz.DocumentListItem/properties/id/required"
      }
    },
    {
      "level": "error",
      "domain": "validation",
      "keyword": "additionalProperties",
      "message": "object instance has properties which are not allowed by the schema: [\"schema\"]",
      "schema": {
        "loadingURI": "http://swagger.io/v2/schema.json#",
        "pointer": "/definitions/schema"
      },
      "instance": {
        "pointer": "/definitions/foo.bar.baz.DocumentListItem/properties/status"
      }
    }
  ]
}

The generated schema:

{
...
  "definitions": {
    "foo.bar.baz.DocumentStatusInfo": {
      "properties": {
        "state": {
          "type": "string",
          "required": true
        },
        "message": {
          "type": "string",
          "required": false
        },
        "timeStamp": {
          "type": "string",
          "required": true
        }
      },
      "required": [
        "state",
        "timeStamp"
      ]
    },
    "foo.bar.baz.DocumentListItem": {
      "properties": {
        "id": {
          "type": "string",
          "required": true
        },
        "name": {
          "type": "string",
          "required": true
        },
        "status": {
          "required": true,
          "schema": {
            "$ref": "#/definitions/foo.bar.baz.DocumentStatusInfo"
          }
        }
      },
      "required": [
        "id",
        "name",
        "status"
      ]
    }
  }
  ...
}

from play-swagger.

kailuowang avatar kailuowang commented on May 26, 2024

@metasim we have the same plan on "generating cross-language bindings against the API" as well, so we also need to a) fix this bug and b) add swagger validator. Any contribution will be much appreciated.

from play-swagger.

kailuowang avatar kailuowang commented on May 26, 2024

I think this is already fixed thanks to #78, please help test.

from play-swagger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.