autodocodec-swagger2 0.0.0.0 → 0.0.1.0
raw patch · 3 files changed
+18/−10 lines, 3 filesdep ~autodocodec
Dependency ranges changed: autodocodec
Files
- CHANGELOG.md +6/−0
- autodocodec-swagger2.cabal +3/−3
- src/Autodocodec/Swagger/Schema.hs +9/−7
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.0.1.0] - 2021-11-19++### Added++* `disjointEitherCodec` now does not generate `additionalProperties = true`.+ ## [0.0.0.0] - 2021-11-19 First release.
autodocodec-swagger2.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.5. -- -- see: https://github.com/sol/hpack name: autodocodec-swagger2-version: 0.0.0.0+version: 0.0.1.0 synopsis: Autodocodec interpreters for swagger2 homepage: https://github.com/NorfairKing/autodocodec#readme bug-reports: https://github.com/NorfairKing/autodocodec/issues@@ -34,7 +34,7 @@ src build-depends: aeson- , autodocodec+ , autodocodec >=0.0.1.0 , base >=4.7 && <5 , insert-ordered-containers , scientific
src/Autodocodec/Swagger/Schema.hs view
@@ -104,12 +104,12 @@ { _schemaParamSchema = mempty {_paramSchemaEnum = Just [toJSONVia valCodec val]} } BimapCodec _ _ c -> go c- EitherCodec c1 c2 -> do+ EitherCodec u c1 c2 -> do ns1 <- go c1 let s1 = _namedSchemaSchema ns1 ns2 <- go c2 let s2 = _namedSchemaSchema ns2- pure $ NamedSchema Nothing $ combineSchemaOr s1 s2+ pure $ NamedSchema Nothing $ combineSchemaOr u s1 s2 CommentCodec t c -> do NamedSchema mName s <- go c pure $ NamedSchema mName $ addDoc t s@@ -160,10 +160,10 @@ ] OptionalKeyWithOmittedDefaultCodec key vs defaultValue mDoc -> goObject (OptionalKeyWithDefaultCodec key vs defaultValue mDoc) PureCodec _ -> pure []- EitherCodec oc1 oc2 -> do+ EitherCodec u oc1 oc2 -> do ss1 <- goObject oc1 ss2 <- goObject oc2- pure [combineSchemaOr (combineObjectSchemas ss1) (combineObjectSchemas ss2)]+ pure [combineSchemaOr u (combineObjectSchemas ss1) (combineObjectSchemas ss2)] ApCodec oc1 oc2 -> do ss1 <- goObject oc1 ss2 <- goObject oc2@@ -180,8 +180,8 @@ } combineObjectSchemas :: [Schema] -> Schema combineObjectSchemas = mconcat- combineSchemaOr :: Schema -> Schema -> Schema- combineSchemaOr s1 s2 =+ combineSchemaOr :: Union -> Schema -> Schema -> Schema+ combineSchemaOr u s1 s2 = let ps1 = _schemaParamSchema s1 ps2 = _schemaParamSchema s2 -- Swagger 2 doesn't support sum types so we have to work around that here.@@ -195,7 +195,9 @@ -- the schema: one which lets any value through. overApproximation = mempty- { _schemaAdditionalProperties = Just $ AdditionalPropertiesAllowed True+ { _schemaAdditionalProperties = case u of+ PossiblyJointUnion -> Just $ AdditionalPropertiesAllowed True+ DisjointUnion -> Nothing } in case (,) <$> _paramSchemaEnum ps1 <*> _paramSchemaEnum ps2 of (Just (es1, es2)) ->