forked from loafle/openapi-generator-original
[General] fix InlineModelResolver's logic and use openapi-generator's InlineModelResolver, so that nested "required" works correctly (#1200)
* fix InlineModelResolver's logis and use openapi-generator's InlineModelResolver, so that nested "required" works correctly * add "required" to nested model schema * update ensure-up-to-date to include openapi v3's jaxrs * change test required field * fix sample shell script, hide timestamp * fix NPE * move test case to petstore-with-fake-endpoints-models-for-testing.yaml * fix jaxrs-jersey (oas3) example generate shell script to use petstore-with-fake-endpoints-models-for-testing.yaml * add default value * re-generate samples
This commit is contained in:
committed by
William Cheng
parent
51d2e4bd4c
commit
bb056ccf3d
@@ -505,7 +505,7 @@ mkCat catClassName =
|
||||
-- | Category
|
||||
data Category = Category
|
||||
{ categoryId :: !(Maybe Integer) -- ^ "id"
|
||||
, categoryName :: !(Maybe Text) -- ^ "name"
|
||||
, categoryName :: !(Text) -- ^ /Required/ "name"
|
||||
} deriving (P.Show, P.Eq, P.Typeable)
|
||||
|
||||
-- | FromJSON Category
|
||||
@@ -513,7 +513,7 @@ instance A.FromJSON Category where
|
||||
parseJSON = A.withObject "Category" $ \o ->
|
||||
Category
|
||||
<$> (o .:? "id")
|
||||
<*> (o .:? "name")
|
||||
<*> (o .: "name")
|
||||
|
||||
-- | ToJSON Category
|
||||
instance A.ToJSON Category where
|
||||
@@ -526,11 +526,12 @@ instance A.ToJSON Category where
|
||||
|
||||
-- | Construct a value of type 'Category' (by applying it's required fields, if any)
|
||||
mkCategory
|
||||
:: Category
|
||||
mkCategory =
|
||||
:: Text -- ^ 'categoryName'
|
||||
-> Category
|
||||
mkCategory categoryName =
|
||||
Category
|
||||
{ categoryId = Nothing
|
||||
, categoryName = Nothing
|
||||
, categoryName
|
||||
}
|
||||
|
||||
-- ** ClassModel
|
||||
|
||||
@@ -185,7 +185,7 @@ categoryIdL f Category{..} = (\categoryId -> Category { categoryId, ..} ) <$> f
|
||||
{-# INLINE categoryIdL #-}
|
||||
|
||||
-- | 'categoryName' Lens
|
||||
categoryNameL :: Lens_' Category (Maybe Text)
|
||||
categoryNameL :: Lens_' Category (Text)
|
||||
categoryNameL f Category{..} = (\categoryName -> Category { categoryName, ..} ) <$> f categoryName
|
||||
{-# INLINE categoryNameL #-}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user