handle composed schemas in InlineModelResolver (#2112)

* handle composed schemas in InlineModelResolver

* fix unit test -> TestUtils.parseSpec

* update samples

* fix samples

* update samples

* update samples

* add new files
This commit is contained in:
Matthieu Berthomé
2019-05-08 04:19:15 +02:00
committed by William Cheng
parent 7eb2be9c99
commit ee43cc1520
412 changed files with 17001 additions and 101 deletions

View File

@@ -723,6 +723,34 @@ mkCat catClassName =
, catDeclawed = Nothing
}
-- ** CatAllOf
-- | CatAllOf
data CatAllOf = CatAllOf
{ catAllOfDeclawed :: !(Maybe Bool) -- ^ "declawed"
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON CatAllOf
instance A.FromJSON CatAllOf where
parseJSON = A.withObject "CatAllOf" $ \o ->
CatAllOf
<$> (o .:? "declawed")
-- | ToJSON CatAllOf
instance A.ToJSON CatAllOf where
toJSON CatAllOf {..} =
_omitNulls
[ "declawed" .= catAllOfDeclawed
]
-- | Construct a value of type 'CatAllOf' (by applying it's required fields, if any)
mkCatAllOf
:: CatAllOf
mkCatAllOf =
CatAllOf
{ catAllOfDeclawed = Nothing
}
-- ** Category
-- | Category
data Category = Category
@@ -850,6 +878,34 @@ mkDog dogClassName =
, dogBreed = Nothing
}
-- ** DogAllOf
-- | DogAllOf
data DogAllOf = DogAllOf
{ dogAllOfBreed :: !(Maybe Text) -- ^ "breed"
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON DogAllOf
instance A.FromJSON DogAllOf where
parseJSON = A.withObject "DogAllOf" $ \o ->
DogAllOf
<$> (o .:? "breed")
-- | ToJSON DogAllOf
instance A.ToJSON DogAllOf where
toJSON DogAllOf {..} =
_omitNulls
[ "breed" .= dogAllOfBreed
]
-- | Construct a value of type 'DogAllOf' (by applying it's required fields, if any)
mkDogAllOf
:: DogAllOf
mkDogAllOf =
DogAllOf
{ dogAllOfBreed = Nothing
}
-- ** EnumArrays
-- | EnumArrays
data EnumArrays = EnumArrays

View File

@@ -281,6 +281,15 @@ catDeclawedL f Cat{..} = (\catDeclawed -> Cat { catDeclawed, ..} ) <$> f catDecl
-- * CatAllOf
-- | 'catAllOfDeclawed' Lens
catAllOfDeclawedL :: Lens_' CatAllOf (Maybe Bool)
catAllOfDeclawedL f CatAllOf{..} = (\catAllOfDeclawed -> CatAllOf { catAllOfDeclawed, ..} ) <$> f catAllOfDeclawed
{-# INLINE catAllOfDeclawedL #-}
-- * Category
-- | 'categoryId' Lens
@@ -332,6 +341,15 @@ dogBreedL f Dog{..} = (\dogBreed -> Dog { dogBreed, ..} ) <$> f dogBreed
-- * DogAllOf
-- | 'dogAllOfBreed' Lens
dogAllOfBreedL :: Lens_' DogAllOf (Maybe Text)
dogAllOfBreedL f DogAllOf{..} = (\dogAllOfBreed -> DogAllOf { dogAllOfBreed, ..} ) <$> f dogAllOfBreed
{-# INLINE dogAllOfBreedL #-}
-- * EnumArrays
-- | 'enumArraysJustSymbol' Lens

View File

@@ -1363,17 +1363,11 @@ components:
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- properties:
breed:
type: string
type: object
- $ref: '#/components/schemas/Dog_allOf'
Cat:
allOf:
- $ref: '#/components/schemas/Animal'
- properties:
declawed:
type: boolean
type: object
- $ref: '#/components/schemas/Cat_allOf'
Animal:
discriminator:
propertyName: className
@@ -2022,6 +2016,14 @@ components:
xml:
namespace: http://a.com/schema
prefix: pre
Dog_allOf:
properties:
breed:
type: string
Cat_allOf:
properties:
declawed:
type: boolean
securitySchemes:
petstore_auth:
flows:

View File

@@ -246,6 +246,14 @@ genCat n =
<*> arbitraryReducedMaybe n -- catColor :: Maybe Text
<*> arbitraryReducedMaybe n -- catDeclawed :: Maybe Bool
instance Arbitrary CatAllOf where
arbitrary = sized genCatAllOf
genCatAllOf :: Int -> Gen CatAllOf
genCatAllOf n =
CatAllOf
<$> arbitraryReducedMaybe n -- catAllOfDeclawed :: Maybe Bool
instance Arbitrary Category where
arbitrary = sized genCategory
@@ -281,6 +289,14 @@ genDog n =
<*> arbitraryReducedMaybe n -- dogColor :: Maybe Text
<*> arbitraryReducedMaybe n -- dogBreed :: Maybe Text
instance Arbitrary DogAllOf where
arbitrary = sized genDogAllOf
genDogAllOf :: Int -> Gen DogAllOf
genDogAllOf n =
DogAllOf
<$> arbitraryReducedMaybe n -- dogAllOfBreed :: Maybe Text
instance Arbitrary EnumArrays where
arbitrary = sized genEnumArrays

View File

@@ -35,10 +35,12 @@ main =
propMimeEq MimeJSON (Proxy :: Proxy ArrayTest)
propMimeEq MimeJSON (Proxy :: Proxy Capitalization)
propMimeEq MimeJSON (Proxy :: Proxy Cat)
propMimeEq MimeJSON (Proxy :: Proxy CatAllOf)
propMimeEq MimeJSON (Proxy :: Proxy Category)
propMimeEq MimeJSON (Proxy :: Proxy ClassModel)
propMimeEq MimeJSON (Proxy :: Proxy Client)
propMimeEq MimeJSON (Proxy :: Proxy Dog)
propMimeEq MimeJSON (Proxy :: Proxy DogAllOf)
propMimeEq MimeJSON (Proxy :: Proxy EnumArrays)
propMimeEq MimeJSON (Proxy :: Proxy EnumClass)
propMimeEq MimeJSON (Proxy :: Proxy EnumTest)