mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
[haskell-servant] Add some missing types to the generated modules (#2675)
* Add some missing types to the generated modules * Run bin/openapi3 script
This commit is contained in:
parent
9dcab9de6b
commit
250e5284cd
@ -301,7 +301,6 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
*/
|
||||
private void setGenerateToSchema(CodegenModel model) {
|
||||
for (CodegenProperty var : model.vars) {
|
||||
LOGGER.warn(var.dataType);
|
||||
if (var.dataType.contentEquals("Value") || var.dataType.contains(" Value")) {
|
||||
additionalProperties.put("generateToSchema", false);
|
||||
}
|
||||
@ -349,7 +348,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String schemaType = super.getSchemaType(p);
|
||||
LOGGER.debug("debugging swager type: " + p.getType() + ", " + p.getFormat() + " => " + schemaType);
|
||||
LOGGER.debug("debugging OpenAPI type: " + p.getType() + ", " + p.getFormat() + " => " + schemaType);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(schemaType)) {
|
||||
type = typeMapping.get(schemaType);
|
||||
|
@ -41,8 +41,10 @@ import Data.Function ((&))
|
||||
import qualified Data.Map as Map
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Set (Set)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Time
|
||||
import Data.UUID (UUID)
|
||||
import GHC.Exts (IsString (..))
|
||||
import GHC.Generics (Generic)
|
||||
|
@ -17,6 +17,7 @@ import Data.List (stripPrefix)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Aeson (Value, FromJSON(..), ToJSON(..), genericToJSON, genericParseJSON)
|
||||
import Data.Aeson.Types (Options(..), defaultOptions)
|
||||
import Data.Set (Set)
|
||||
import Data.Text (Text)
|
||||
import Data.Time
|
||||
import Data.Swagger (ToSchema, declareNamedSchema)
|
||||
|
@ -1 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
4.0.0-beta3
|
@ -41,8 +41,10 @@ import Data.Function ((&))
|
||||
import qualified Data.Map as Map
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Set (Set)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Time
|
||||
import Data.UUID (UUID)
|
||||
import GHC.Exts (IsString (..))
|
||||
import GHC.Generics (Generic)
|
||||
@ -135,7 +137,7 @@ type OpenAPIPetstoreAPI
|
||||
= "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route
|
||||
:<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' route
|
||||
:<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByStatus' route
|
||||
:<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route
|
||||
:<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> QueryParam "maxCount" Int :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route
|
||||
:<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route
|
||||
:<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route
|
||||
:<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' route
|
||||
@ -174,7 +176,7 @@ data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend
|
||||
{ addPet :: Pet -> m (){- ^ -}
|
||||
, deletePet :: Integer -> Maybe Text -> m (){- ^ -}
|
||||
, findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -}
|
||||
, findPetsByTags :: Maybe [Text] -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -}
|
||||
, findPetsByTags :: Maybe [Text] -> Maybe Int -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -}
|
||||
, getPetById :: Integer -> m Pet{- ^ Returns a single pet -}
|
||||
, updatePet :: Pet -> m (){- ^ -}
|
||||
, updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -}
|
||||
|
@ -6,6 +6,8 @@
|
||||
module OpenAPIPetstore.Types (
|
||||
ApiResponse (..),
|
||||
Category (..),
|
||||
InlineObject (..),
|
||||
InlineObject1 (..),
|
||||
Order (..),
|
||||
Pet (..),
|
||||
Tag (..),
|
||||
@ -18,6 +20,7 @@ import Data.List (stripPrefix)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Aeson (Value, FromJSON(..), ToJSON(..), genericToJSON, genericParseJSON)
|
||||
import Data.Aeson.Types (Options(..), defaultOptions)
|
||||
import Data.Set (Set)
|
||||
import Data.Text (Text)
|
||||
import Data.Time
|
||||
import Data.Swagger (ToSchema, declareNamedSchema)
|
||||
@ -62,6 +65,38 @@ instance ToSchema Category where
|
||||
$ removeFieldLabelPrefix False "category"
|
||||
|
||||
|
||||
-- |
|
||||
data InlineObject = InlineObject
|
||||
{ inlineObjectName :: Maybe Text -- ^ Updated name of the pet
|
||||
, inlineObjectStatus :: Maybe Text -- ^ Updated status of the pet
|
||||
} deriving (Show, Eq, Generic, Data)
|
||||
|
||||
instance FromJSON InlineObject where
|
||||
parseJSON = genericParseJSON (removeFieldLabelPrefix True "inlineObject")
|
||||
instance ToJSON InlineObject where
|
||||
toJSON = genericToJSON (removeFieldLabelPrefix False "inlineObject")
|
||||
instance ToSchema InlineObject where
|
||||
declareNamedSchema = Swagger.genericDeclareNamedSchema
|
||||
$ Swagger.fromAesonOptions
|
||||
$ removeFieldLabelPrefix False "inlineObject"
|
||||
|
||||
|
||||
-- |
|
||||
data InlineObject1 = InlineObject1
|
||||
{ inlineObject1AdditionalMetadata :: Maybe Text -- ^ Additional data to pass to server
|
||||
, inlineObject1File :: Maybe FilePath -- ^ file to upload
|
||||
} deriving (Show, Eq, Generic, Data)
|
||||
|
||||
instance FromJSON InlineObject1 where
|
||||
parseJSON = genericParseJSON (removeFieldLabelPrefix True "inlineObject1")
|
||||
instance ToJSON InlineObject1 where
|
||||
toJSON = genericToJSON (removeFieldLabelPrefix False "inlineObject1")
|
||||
instance ToSchema InlineObject1 where
|
||||
declareNamedSchema = Swagger.genericDeclareNamedSchema
|
||||
$ Swagger.fromAesonOptions
|
||||
$ removeFieldLabelPrefix False "inlineObject1"
|
||||
|
||||
|
||||
-- | An order for a pets from the pet store
|
||||
data Order = Order
|
||||
{ orderId :: Maybe Integer -- ^
|
||||
|
Loading…
Reference in New Issue
Block a user