@@ -38,10 +38,13 @@ import Network (HostName, PortNumber)
38import Network.HTTP.Media (MediaType)
38import Network.HTTP.Media (MediaType)
39import Text.Read (readMaybe)
39import Text.Read (readMaybe)
41+import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
42+import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
41import Data.Swagger.Internal.Utils
44import Data.Swagger.Internal.Utils
43-- | A list of definitions that can be used in references.
46-- | A list of definitions that can be used in references.
44−type Definitions = HashMap Text
47+type Definitions = InsOrdHashMap Text
46-- | This is the root document object for the API specification.
49-- | This is the root document object for the API specification.
47data Swagger = Swagger
50data Swagger = Swagger
@@ -73,7 +76,7 @@ data Swagger = Swagger
73 -- | The available paths and operations for the API.
76 -- | The available paths and operations for the API.
74 -- Holds the relative paths to the individual endpoints.
77 -- Holds the relative paths to the individual endpoints.
75 -- The path is appended to the @'basePath'@ in order to construct the full URL.
78 -- The path is appended to the @'basePath'@ in order to construct the full URL.
76− , _swaggerPaths :: HashMap FilePath PathItem
79+ , _swaggerPaths :: InsOrdHashMap FilePath PathItem
78 -- | An object to hold data types produced and consumed by operations.
81 -- | An object to hold data types produced and consumed by operations.
79 , _swaggerDefinitions :: Definitions Schema
82 , _swaggerDefinitions :: Definitions Schema
@@ -482,7 +485,7 @@ data Schema = Schema
482 , _schemaRequired :: [ParamName]
485 , _schemaRequired :: [ParamName]
484 , _schemaAllOf :: Maybe [Schema]
487 , _schemaAllOf :: Maybe [Schema]
485− , _schemaProperties :: HashMap Text (Referenced Schema)
488+ , _schemaProperties :: InsOrdHashMap Text (Referenced Schema)
486 , _schemaAdditionalProperties :: Maybe (Referenced Schema)
489 , _schemaAdditionalProperties :: Maybe (Referenced Schema)
488 , _schemaDiscriminator :: Maybe Text
491 , _schemaDiscriminator :: Maybe Text
@@ -574,7 +577,7 @@ data Responses = Responses
575 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
578 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
576 -- Describes the expected response for those HTTP status codes.
579 -- Describes the expected response for those HTTP status codes.
577− , _responsesResponses :: HashMap HttpStatusCode (Referenced Response)
580+ , _responsesResponses :: InsOrdHashMap HttpStatusCode (Referenced Response)
578 } deriving (Eq, Show, Generic, Data, Typeable)
581 } deriving (Eq, Show, Generic, Data, Typeable)
580type HttpStatusCode = Int
583type HttpStatusCode = Int
@@ -593,7 +596,7 @@ data Response = Response
593 , _responseSchema :: Maybe (Referenced Schema)
596 , _responseSchema :: Maybe (Referenced Schema)
595 -- | A list of headers that are sent with the response.
598 -- | A list of headers that are sent with the response.
596− , _responseHeaders :: HashMap HeaderName Header
599+ , _responseHeaders :: InsOrdHashMap HeaderName Header
598 -- | An example of the response message.
601 -- | An example of the response message.
599 , _responseExamples :: Maybe Example
602 , _responseExamples :: Maybe Example
@@ -659,7 +662,7 @@ data OAuth2Params = OAuth2Params
659 _oauth2Flow :: OAuth2Flow
662 _oauth2Flow :: OAuth2Flow
661 -- | The available scopes for the OAuth2 security scheme.
664 -- | The available scopes for the OAuth2 security scheme.
662− , _oauth2Scopes :: HashMap Text Text
665+ , _oauth2Scopes :: InsOrdHashMap Text Text
663 } deriving (Eq, Show, Generic, Data, Typeable)
666 } deriving (Eq, Show, Generic, Data, Typeable)
665data SecuritySchemeType
668data SecuritySchemeType
@@ -680,7 +683,7 @@ data SecurityScheme = SecurityScheme
680-- The object can have multiple security schemes declared in it which are all required
683-- The object can have multiple security schemes declared in it which are all required
681-- (that is, there is a logical AND between the schemes).
684-- (that is, there is a logical AND between the schemes).
682newtype SecurityRequirement = SecurityRequirement
685newtype SecurityRequirement = SecurityRequirement
683− { getSecurityRequirement :: HashMap Text [Text]
686+ { getSecurityRequirement :: InsOrdHashMap Text [Text]
684 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON, Data, Typeable)
687 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON, Data, Typeable)
686-- | Tag name.
689-- | Tag name.
@@ -818,6 +821,10 @@ instance OVERLAPPING_ SwaggerMonoid (HashMap FilePath PathItem) where
818 swaggerMempty = HashMap.empty
821 swaggerMempty = HashMap.empty
819 swaggerMappend = HashMap.unionWith mappend
822 swaggerMappend = HashMap.unionWith mappend
824+instance OVERLAPPING_ SwaggerMonoid (InsOrdHashMap FilePath PathItem) where
825+ swaggerMempty = InsOrdHashMap.empty
826+ swaggerMappend = InsOrdHashMap.unionWith mappend
821instance Monoid a => SwaggerMonoid (Referenced a) where
828instance Monoid a => SwaggerMonoid (Referenced a) where
822 swaggerMempty = Inline mempty
829 swaggerMempty = Inline mempty
823 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
830 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
@@ -972,7 +979,7 @@ instance ToJSON ParamOtherSchema where
973instance ToJSON Responses where
980instance ToJSON Responses where
974 toJSON (Responses def rs) = omitEmpties $
981 toJSON (Responses def rs) = omitEmpties $
975− toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
982+ toJSON (InsOrdHashMap.mapKeys show rs) <+> object [ "default" .= def ]
977instance ToJSON Response where
984instance ToJSON Response where
978 toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
985 toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
@@ -1071,7 +1078,7 @@ instance FromJSON SecurityScheme where
1072instance FromJSON Schema where
1079instance FromJSON Schema where
1073 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "schema")
1080 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "schema")
1074− `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
1081+ `withDefaults` [ "properties" .= (mempty :: InsOrdHashMap Text Schema)
1075 , "required" .= ([] :: [ParamName]) ]
1082 , "required" .= ([] :: [ParamName]) ]
1077instance FromJSON Header where
1084instance FromJSON Header where
@@ -1118,7 +1125,7 @@ instance FromJSON ParamOtherSchema where
1118instance FromJSON Responses where
1125instance FromJSON Responses where
1119 parseJSON (Object o) = Responses
1126 parseJSON (Object o) = Responses
1120 <$> o .:? "default"
1127 <$> o .:? "default"
1121− <*> (parseJSON (Object (HashMap.delete "default" o)) >>= hashMapReadKeys)
1128+ <*> (parseJSON (Object (HashMap.delete "default" o)))
1122 parseJSON _ = empty
1129 parseJSON _ = empty
1124instance FromJSON Example where
1131instance FromJSON Example where
@@ -1128,7 +1135,7 @@ instance FromJSON Example where
1129instance FromJSON Response where
1136instance FromJSON Response where
1130 parseJSON = genericParseJSON (jsonPrefix "response")
1137 parseJSON = genericParseJSON (jsonPrefix "response")
1131− `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName Header) ]
1138+ `withDefaults` [ "headers" .= (mempty :: InsOrdHashMap HeaderName Header) ]
1133instance FromJSON Operation where
1140instance FromJSON Operation where
1134 parseJSON = genericParseJSON (jsonPrefix "operation")
1141 parseJSON = genericParseJSON (jsonPrefix "operation")