@@ -38,10 +38,13 @@ import Network (HostName, PortNumber)
3838import Network.HTTP.Media (MediaType)
3939import Text.Read (readMaybe)
4040
41+import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
42+import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
43+
4144import Data.Swagger.Internal.Utils
4245
4346-- | A list of definitions that can be used in references.
44−type Definitions = HashMap Text
47+type Definitions = InsOrdHashMap Text
4548
4649-- | This is the root document object for the API specification.
4750data Swagger = Swagger
@@ -73,7 +76,7 @@ data Swagger = Swagger
7376 -- | The available paths and operations for the API.
7477 -- Holds the relative paths to the individual endpoints.
7578 -- The path is appended to the @'basePath'@ in order to construct the full URL.
76− , _swaggerPaths :: HashMap FilePath PathItem
79+ , _swaggerPaths :: InsOrdHashMap FilePath PathItem
7780
7881 -- | An object to hold data types produced and consumed by operations.
7982 , _swaggerDefinitions :: Definitions Schema
@@ -482,7 +485,7 @@ data Schema = Schema
482485 , _schemaRequired :: [ParamName]
483486
484487 , _schemaAllOf :: Maybe [Schema]
485− , _schemaProperties :: HashMap Text (Referenced Schema)
488+ , _schemaProperties :: InsOrdHashMap Text (Referenced Schema)
486489 , _schemaAdditionalProperties :: Maybe (Referenced Schema)
487490
488491 , _schemaDiscriminator :: Maybe Text
@@ -574,7 +577,7 @@ data Responses = Responses
574577
575578 -- | Any HTTP status code can be used as the property name (one property per HTTP status code).
576579 -- Describes the expected response for those HTTP status codes.
577− , _responsesResponses :: HashMap HttpStatusCode (Referenced Response)
580+ , _responsesResponses :: InsOrdHashMap HttpStatusCode (Referenced Response)
578581 } deriving (Eq, Show, Generic, Data, Typeable)
579582
580583type HttpStatusCode = Int
@@ -593,7 +596,7 @@ data Response = Response
593596 , _responseSchema :: Maybe (Referenced Schema)
594597
595598 -- | A list of headers that are sent with the response.
596− , _responseHeaders :: HashMap HeaderName Header
599+ , _responseHeaders :: InsOrdHashMap HeaderName Header
597600
598601 -- | An example of the response message.
599602 , _responseExamples :: Maybe Example
@@ -659,7 +662,7 @@ data OAuth2Params = OAuth2Params
659662 _oauth2Flow :: OAuth2Flow
660663
661664 -- | The available scopes for the OAuth2 security scheme.
662− , _oauth2Scopes :: HashMap Text Text
665+ , _oauth2Scopes :: InsOrdHashMap Text Text
663666 } deriving (Eq, Show, Generic, Data, Typeable)
664667
665668data SecuritySchemeType
@@ -680,7 +683,7 @@ data SecurityScheme = SecurityScheme
680683-- The object can have multiple security schemes declared in it which are all required
681684-- (that is, there is a logical AND between the schemes).
682685newtype SecurityRequirement = SecurityRequirement
683− { getSecurityRequirement :: HashMap Text [Text]
686+ { getSecurityRequirement :: InsOrdHashMap Text [Text]
684687 } deriving (Eq, Read, Show, Monoid, ToJSON, FromJSON, Data, Typeable)
685688
686689-- | Tag name.
@@ -818,6 +821,10 @@ instance OVERLAPPING_ SwaggerMonoid (HashMap FilePath PathItem) where
818821 swaggerMempty = HashMap.empty
819822 swaggerMappend = HashMap.unionWith mappend
820823
824+instance OVERLAPPING_ SwaggerMonoid (InsOrdHashMap FilePath PathItem) where
825+ swaggerMempty = InsOrdHashMap.empty
826+ swaggerMappend = InsOrdHashMap.unionWith mappend
827+
821828instance Monoid a => SwaggerMonoid (Referenced a) where
822829 swaggerMempty = Inline mempty
823830 swaggerMappend (Inline x) (Inline y) = Inline (x <> y)
@@ -972,7 +979,7 @@ instance ToJSON ParamOtherSchema where
972979
973980instance ToJSON Responses where
974981 toJSON (Responses def rs) = omitEmpties $
975− toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
982+ toJSON (InsOrdHashMap.mapKeys show rs) <+> object [ "default" .= def ]
976983
977984instance ToJSON Response where
978985 toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
@@ -1071,7 +1078,7 @@ instance FromJSON SecurityScheme where
10711078
10721079instance FromJSON Schema where
10731080 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "schema")
1074− `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
1081+ `withDefaults` [ "properties" .= (mempty :: InsOrdHashMap Text Schema)
10751082 , "required" .= ([] :: [ParamName]) ]
10761083
10771084instance FromJSON Header where
@@ -1118,7 +1125,7 @@ instance FromJSON ParamOtherSchema where
11181125instance FromJSON Responses where
11191126 parseJSON (Object o) = Responses
11201127 <$> o .:? "default"
1121− <*> (parseJSON (Object (HashMap.delete "default" o)) >>= hashMapReadKeys)
1128+ <*> (parseJSON (Object (HashMap.delete "default" o)))
11221129 parseJSON _ = empty
11231130
11241131instance FromJSON Example where
@@ -1128,7 +1135,7 @@ instance FromJSON Example where
11281135
11291136instance FromJSON Response where
11301137 parseJSON = genericParseJSON (jsonPrefix "response")
1131− `withDefaults` [ "headers" .= (mempty :: HashMap HeaderName Header) ]
1138+ `withDefaults` [ "headers" .= (mempty :: InsOrdHashMap HeaderName Header) ]
11321139
11331140instance FromJSON Operation where
11341141 parseJSON = genericParseJSON (jsonPrefix "operation")