GetShopTV / swagger2

Swagger 2.0 data model.
http://hackage.haskell.org/package/swagger2
BSD 3-Clause "New" or "Revised" License
74 stars 59 forks source link

Test failures with hashable 1.3.1.0 #222

Closed felixonmars closed 2 years ago

felixonmars commented 3 years ago

They all pass with hashable 1.3.0.0 and others unchanged.

Running 2 test suites...
Test suite spec: RUNNING...
Test suite spec: PASS
Test suite logged to: dist/test/swagger2-2.6-spec.log
Test suite doctests: RUNNING...
/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger.hs:147: failure in expression `encode (mempty :: Swagger)'
expected: "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"}}"
 but got: "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"}}"
                                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger.hs:187: failure in expression `:{
 encode $ (mempty :: Swagger)
   & definitions .~ [ ("User", mempty & type_ ?~ SwaggerString) ]
   & paths .~
     [ ("/user", mempty & get ?~ (mempty
         & produces ?~ MimeList ["application/json"]
         & at 200 ?~ ("OK" & _Inline.schema ?~ Ref (Reference "User"))
         & at 404 ?~ "User info not found")) ]
:}'
expected: "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"produces\":[\"application/json\"],\"responses\":{\"404\":{\"description\":\"User info not found\"},\"200\":{\"schema\":{\"$ref\":\"#/definitions/User\"},\"description\":\"OK\"}}}}},\"definitions\":{\"User\":{\"type\":\"string\"}}}"
 but got: "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"produces\":[\"application/json\"],\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/User\"},\"description\":\"OK\"},\"404\":{\"description\":\"User info not found\"}}}}},\"definitions\":{\"User\":{\"type\":\"string\"}}}"
                                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger.hs:278: failure in expression `encode (Person "David" 28)'
expected: "{\"age\":28,\"name\":\"David\"}"
 but got: "{\"name\":\"David\",\"age\":28}"
              ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema/Validation.hs:93: failure in expression `traverse_ putStrLn $ renderValidationErrors validateToJSON person'
expected: Validation against the schema fails:
            * property "phone" is required, but not found in "{\"name\":\"John\"}"

          JSON value:
          {
              "name": "John"
          }

          Swagger Schema:
          {
              "required": [
                  "name",
                  "phone"
              ],
              "type": "object",
              "properties": {
                  "phone": {
                      "$ref": "#/definitions/Phone"
                  },
                  "name": {
                      "type": "string"
                  }
              }
          }

          Swagger Description Context:
          {
              "Phone": {
                  "required": [
                      "value"
                  ],
                  "type": "object",
                  "properties": {
                      "value": {
                          "type": "string"
                      }
                  }
              }
          }

 but got: Validation against the schema fails:
            * property "phone" is required, but not found in "{\"name\":\"John\"}"

          JSON value:
          {
              "name": "John"
          }

          Swagger Schema:
          {
              "required": [
                  "name",
                  "phone"
              ],
              "properties": {
               ^
                  "name": {
                      "type": "string"
                  },
                  "phone": {
                      "$ref": "#/definitions/Phone"
                  }
              },
              "type": "object"
          }

          Swagger Description Context:
          {
              "Phone": {
                  "required": [
                      "value"
                  ],
                  "properties": {
                      "value": {
                          "type": "string"
                      }
                  },
                  "type": "object"
              }
          }

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Operation.hs:82: failure in expression `encode api'
expected: "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"description\":\"OK\"}}},\"post\":{\"responses\":{\"200\":{\"description\":\"OK\"}}}}}}"
 but got: "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"description\":\"OK\"}}},\"post\":{\"responses\":{\"200\":{\"description\":\"OK\"}}}}}}"
                                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Operation.hs:141: failure in expression `encode $ api & setResponse 200 res'
expected: "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/Day\"},\"description\":\"\"}}}}},\"definitions\":{\"Day\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}}}"
 but got: "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/Day\"},\"description\":\"\"}}}}},\"definitions\":{\"Day\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}}}"
                                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema.hs:184: failure in expression `encode $ toSchema (Proxy :: Proxy Int8)'
expected: "{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"
 but got: "{\"minimum\":-128,\"type\":\"integer\",\"maximum\":127}"
               ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema.hs:267: failure in expression `encode $ toInlinedSchema (Proxy :: Proxy [Day])'
expected: "{\"items\":{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"},\"type\":\"array\"}"
 but got: "{\"items\":{\"format\":\"date\",\"type\":\"string\",\"example\":\"2016-07-22\"},\"type\":\"array\"}"
                         ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema.hs:331: failure in expression `encode $ sketchSchema (Person "Jack" 25)'
expected: "{\"required\":[\"age\",\"name\"],\"properties\":{\"age\":{\"type\":\"number\"},\"name\":{\"type\":\"string\"}},\"example\":{\"age\":25,\"name\":\"Jack\"},\"type\":\"object\"}"
 but got: "{\"required\":[\"name\",\"age\"],\"properties\":{\"name\":{\"type\":\"string\"},\"age\":{\"type\":\"number\"}},\"example\":{\"name\":\"Jack\",\"age\":25},\"type\":\"object\"}"
                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema.hs:364: failure in expression `encode $ sketchStrictSchema "hello"'
expected: "{\"maxLength\":5,\"pattern\":\"hello\",\"minLength\":5,\"type\":\"string\",\"enum\":[\"hello\"]}"
 but got: "{\"minLength\":5,\"enum\":[\"hello\"],\"maxLength\":5,\"pattern\":\"hello\",\"type\":\"string\"}"
               ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/Schema.hs:598: failure in expression `encode $ toSchemaBoundedIntegral (Proxy :: Proxy Int16)'
expected: "{\"maximum\":32767,\"minimum\":-32768,\"type\":\"integer\"}"
 but got: "{\"minimum\":-32768,\"type\":\"integer\",\"maximum\":32767}"
               ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/ParamSchema.hs:155: failure in expression `encode $ toParamSchemaBoundedIntegral (Proxy :: Proxy Int8)'
expected: "{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"
 but got: "{\"minimum\":-128,\"type\":\"integer\",\"maximum\":127}"
               ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/ParamSchema.hs:279: failure in expression `encode $ toParamSchema (Proxy :: Proxy ())'
expected: "{\"type\":\"string\",\"enum\":[\"_\"]}"
 but got: "{\"enum\":[\"_\"],\"type\":\"string\"}"
              ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal/ParamSchema.hs:295: failure in expression `encode $ genericToParamSchema defaultSchemaOptions (Proxy :: Proxy Color)'
expected: "{\"type\":\"string\",\"enum\":[\"Red\",\"Blue\"]}"
 but got: "{\"enum\":[\"Red\",\"Blue\"],\"type\":\"string\"}"
              ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Optics.hs:23: failure in expression `:{
 encode $ (mempty :: Swagger)
   & #definitions .~ [ ("User", mempty & #type ?~ SwaggerString) ]
   & #paths .~
     [ ("/user", mempty & #get ?~ (mempty
         & #produces ?~ MimeList ["application/json"]
         & at 200 ?~ ("OK" & #_Inline % #schema ?~ Ref (Reference "User"))
         & at 404 ?~ "User info not found")) ]
:}'
expected: "{\"swagger\":\"2.0\",\"info\":{\"version\":\"\",\"title\":\"\"},\"paths\":{\"/user\":{\"get\":{\"produces\":[\"application/json\"],\"responses\":{\"404\":{\"description\":\"User info not found\"},\"200\":{\"schema\":{\"$ref\":\"#/definitions/User\"},\"description\":\"OK\"}}}}},\"definitions\":{\"User\":{\"type\":\"string\"}}}"
 but got: "{\"swagger\":\"2.0\",\"info\":{\"title\":\"\",\"version\":\"\"},\"paths\":{\"/user\":{\"get\":{\"produces\":[\"application/json\"],\"responses\":{\"200\":{\"schema\":{\"$ref\":\"#/definitions/User\"},\"description\":\"OK\"},\"404\":{\"description\":\"User info not found\"}}}}},\"definitions\":{\"User\":{\"type\":\"string\"}}}"
                                            ^

/build/haskell-swagger2/src/swagger2-2.6/src/Data/Swagger/Internal.hs:1094: failure in expression `encode (SwaggerItemsArray [])'
expected: "{\"example\":[],\"items\":{},\"maxItems\":0}"
 but got: "{\"items\":{},\"example\":[],\"maxItems\":0}"
              ^

Examples: 145  Tried: 121  Errors: 0  Failures: 16
-i
-i/build/haskell-swagger2/src/swagger2-2.6/dist/build/autogen
-i/build/haskell-swagger2/src/swagger2-2.6/dist/build
-i/build/haskell-swagger2/src/swagger2-2.6/src
-I/build/haskell-swagger2/src/swagger2-2.6/include
-package-env=-
-hide-all-packages
-no-user-package-db
-package-db=dist/package.conf.inplace
-optP-include
-optPdist/build/autogen/cabal_macros.h
-package-id=QuickCheck-2.14.2-IqL8Pekwyon8v1lNoFQeCa
-package-id=aeson-1.5.5.1-COpvyv5A5FM9WahQ1eKo2T
-package-id=aeson-pretty-0.8.8-HY5VPqKzeRI6nlzGjKriCW
-package-id=base-4.14.1.0
-package-id=base-compat-batteries-0.11.2-498Vn6aZw4S6epHcisIbyF
-package-id=bytestring-0.10.12.0
-package-id=containers-0.6.2.1
-package-id=cookie-0.4.5-Cr058gEywdbK8YE1EhasZd
-package-id=generics-sop-0.5.1.0-mubOomgjQl1sB1sC41AXz
-package-id=hashable-1.3.1.0-1ltFuSWBdj46WMUtk4stqw
-package-id=http-media-0.8.0.0-1NYhQP59hRSH0FMn7KCuEH
-package-id=insert-ordered-containers-0.2.3.1-DJ2XFCT4IZyADhl4tI7ymo
-package-id=lens-4.19.2-6gUdGTQnNLdHCR0HsLPgTb
-package-id=mtl-2.2.2
-package-id=network-3.1.2.1-1jc54hmJxBnERsSm5RSj1b
-package-id=optics-core-0.3.0.1-BMRC4TZxLueHQKDtrcmNn
-package-id=optics-th-0.3.0.2-Kr453RLBmGY3XxWq9nKKqZ
-package-id=scientific-0.3.6.2-IbsGAoJcbbX9we1IpeokRs
-package-id=template-haskell-2.16.0.0
-package-id=text-1.2.4.1
-package-id=time-1.9.3
-package-id=transformers-0.5.6.2
-package-id=transformers-compat-0.6.6-5ZJJ9POl5DGLIWTn4Z8HjM
-package-id=unordered-containers-0.2.13.0-CWXXo6HWEZeChvNNcczQhb
-package-id=uuid-types-1.0.3-EbT0kCJAA5n4ZOVlrhAmkT
-package-id=vector-0.12.2.0-8pf44UKlDjjJbWw9drOzDp
-package-id=Glob-0.10.1-5IMO8GtJHbNB7YMkB6x2kf
-package-id=doctest-0.18-JPATmyrJqBB5HHuCmHJOib
Data.Swagger
Data.Swagger.Declare
Data.Swagger.Lens
Data.Swagger.Operation
Data.Swagger.Optics
Data.Swagger.ParamSchema
Data.Swagger.Schema
Data.Swagger.Schema.Generator
Data.Swagger.Schema.Validation
Data.Swagger.SchemaOptions
Data.Swagger.Internal
Data.Swagger.Internal.Schema
Data.Swagger.Internal.Schema.Validation
Data.Swagger.Internal.ParamSchema
Data.Swagger.Internal.Utils
Data.Swagger.Internal.AesonUtils
Data.Swagger.Internal.TypeShape
Test suite doctests: FAIL
Test suite logged to: dist/test/swagger2-2.6-doctests.log
1 of 2 test suites (1 of 2 test cases) passed.
ysangkok commented 2 years ago

Is this still an issue after /pull/228 ?

swamp-agr commented 2 years ago

@felixonmars feel free to re-open issue if it still reproduces for you after release. The current one is 2.8.3.

felixonmars commented 2 years ago

Thanks, it works correctly with 2.8.1 as we just recently updated to. Sorry for the late response!