Skip to content

Commit

Permalink
Fixes #132
Browse files Browse the repository at this point in the history
The original code seems to check whether the type is really a
type constructor thus starting with an upper case letter.
The problem is that this check is done on the transformed name
of the type, which may no longer be an upper case letter
(e.g. when one uses camelTo2 '_'). Therefore, the check should
be done on the original name of the type, which then fixes
issue #132.
  • Loading branch information
Adriaan Middelkoop committed Oct 24, 2017
1 parent f014fbc commit 4ce7dc9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Data/Swagger/Internal/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,12 @@ genericNameSchema :: forall a d f proxy.
genericNameSchema opts _ = NamedSchema (gdatatypeSchemaName opts (Proxy :: Proxy d))

gdatatypeSchemaName :: forall proxy d. Datatype d => SchemaOptions -> proxy d -> Maybe T.Text
gdatatypeSchemaName opts _ = case name of
gdatatypeSchemaName opts _ = case orig of
(c:_) | isAlpha c && isUpper c -> Just (T.pack name)
_ -> Nothing
where
name = datatypeNameModifier opts (datatypeName (Proxy3 :: Proxy3 d f a))
orig = datatypeName (Proxy3 :: Proxy3 d f a)
name = datatypeNameModifier opts orig

-- | Lift a plain @'ParamSchema'@ into a model @'NamedSchema'@.
paramSchemaToNamedSchema :: forall a d f proxy.
Expand Down

0 comments on commit 4ce7dc9

Please sign in to comment.