diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 1dc1cd8713b5..1d9d27eb4716 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -225,7 +225,7 @@ apiTemplateFiles are for API outputs only (controllers/handlers). // How to encode special characters like $ // They are translated to words like "Dollar" and prefixed with ' // Then translated back during JSON encoding and decoding - protected Map specialCharReplacements = new HashMap<>(); + protected Map specialCharReplacements = new LinkedHashMap<>(); // When a model is an alias for a simple type protected Map typeAliases = null; protected Boolean prependFormOrBodyParameters = false; @@ -512,7 +512,7 @@ protected Map getModelNameToSchemaCache() { * @return map of all models indexed by names */ public Map getAllModels(Map objs) { - Map allModels = new HashMap<>(); + Map allModels = new LinkedHashMap<>(); for (Entry entry : objs.entrySet()) { String modelName = toModelName(entry.getKey()); List models = entry.getValue().getModels(); diff --git a/modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto b/modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto index be5371035c98..3e85147a66d0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto +++ b/modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto @@ -12,21 +12,18 @@ syntax = "proto3"; package openapitools; -import public "models/lizard_all_of.proto"; -import public "models/snake_all_of.proto"; import public "models/cat_all_of.proto"; import public "models/dog_all_of.proto"; +import public "models/lizard_all_of.proto"; message Pet { string petType = 140636936; - bool hasLegs = 159828448; - - bool lovesRocks = 499337491; - string name = 3373707; string bark = 3016376; + bool lovesRocks = 499337491; + } diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Animal.cs index e2578a131490..d06c695fa6ab 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Animal.cs @@ -30,8 +30,8 @@ namespace Org.OpenAPITools.Model /// [DataContract] [JsonConverter(typeof(JsonSubtypes), "className")] - [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] [JsonSubtypes.KnownSubType(typeof(Cat), "Cat")] + [JsonSubtypes.KnownSubType(typeof(Dog), "Dog")] public partial class Animal : IEquatable, IValidatableObject { /// diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/animal.py b/samples/client/petstore/python-asyncio/petstore_api/models/animal.py index eee29f37f881..335eb2625af4 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/animal.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/animal.py @@ -46,9 +46,9 @@ class Animal(object): } discriminator_value_class_map = { - 'Dog': 'Dog', + 'BigCat': 'BigCat', 'Cat': 'Cat', - 'BigCat': 'BigCat' + 'Dog': 'Dog' } def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501 diff --git a/samples/client/petstore/python-legacy/petstore_api/models/animal.py b/samples/client/petstore/python-legacy/petstore_api/models/animal.py index eee29f37f881..335eb2625af4 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/animal.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/animal.py @@ -46,9 +46,9 @@ class Animal(object): } discriminator_value_class_map = { - 'Dog': 'Dog', + 'BigCat': 'BigCat', 'Cat': 'Cat', - 'BigCat': 'BigCat' + 'Dog': 'Dog' } def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501 diff --git a/samples/client/petstore/python-tornado/petstore_api/models/animal.py b/samples/client/petstore/python-tornado/petstore_api/models/animal.py index eee29f37f881..335eb2625af4 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/animal.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/animal.py @@ -46,9 +46,9 @@ class Animal(object): } discriminator_value_class_map = { - 'Dog': 'Dog', + 'BigCat': 'BigCat', 'Cat': 'Cat', - 'BigCat': 'BigCat' + 'Dog': 'Dog' } def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py index 1a36f3398fff..d4a49534078d 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py @@ -46,8 +46,8 @@ class Animal(object): } discriminator_value_class_map = { - 'Dog': 'Dog', - 'Cat': 'Cat' + 'Cat': 'Cat', + 'Dog': 'Dog' } def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501 diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs index 9bb39c771ab6..7c19368f7c23 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs @@ -160,42 +160,42 @@ removeFieldLabelPrefix forParsing prefix = where replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars) specialChars = - [ ("@", "'At") - , ("\\", "'Back_Slash") - , ("<=", "'Less_Than_Or_Equal_To") - , ("\"", "'Double_Quote") - , ("[", "'Left_Square_Bracket") - , ("]", "'Right_Square_Bracket") + [ ("$", "'Dollar") , ("^", "'Caret") - , ("_", "'Underscore") - , ("`", "'Backtick") - , ("!", "'Exclamation") - , ("#", "'Hash") - , ("$", "'Dollar") - , ("%", "'Percent") - , ("&", "'Ampersand") - , ("'", "'Quote") - , ("(", "'Left_Parenthesis") - , (")", "'Right_Parenthesis") + , ("|", "'Pipe") + , ("=", "'Equal") , ("*", "'Star") - , ("+", "'Plus") - , (",", "'Comma") , ("-", "'Dash") - , (".", "'Period") - , ("/", "'Slash") + , ("&", "'Ampersand") + , ("%", "'Percent") + , ("#", "'Hash") + , ("@", "'At") + , ("!", "'Exclamation") + , ("+", "'Plus") , (":", "'Colon") , (";", "'Semicolon") - , ("{", "'Left_Curly_Bracket") - , ("|", "'Pipe") + , (">", "'GreaterThan") , ("<", "'LessThan") - , ("!=", "'Not_Equal") - , ("=", "'Equal") + , (".", "'Period") + , ("_", "'Underscore") + , ("?", "'Question_Mark") + , (",", "'Comma") + , ("'", "'Quote") + , ("/", "'Slash") + , ("(", "'Left_Parenthesis") + , (")", "'Right_Parenthesis") + , ("{", "'Left_Curly_Bracket") , ("}", "'Right_Curly_Bracket") - , (">", "'GreaterThan") + , ("[", "'Left_Square_Bracket") + , ("]", "'Right_Square_Bracket") , ("~", "'Tilde") - , ("?", "'Question_Mark") + , ("`", "'Backtick") + , ("<=", "'Less_Than_Or_Equal_To") , (">=", "'Greater_Than_Or_Equal_To") + , ("!=", "'Not_Equal") , ("~=", "'Tilde_Equal") + , ("\\", "'Back_Slash") + , ("\"", "'Double_Quote") ] mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack replacer = diff --git a/samples/server/petstore/haskell-yesod/src/OpenAPIPetstore/Types.hs b/samples/server/petstore/haskell-yesod/src/OpenAPIPetstore/Types.hs index 1ba7c5d14872..7057e0e55dac 100644 --- a/samples/server/petstore/haskell-yesod/src/OpenAPIPetstore/Types.hs +++ b/samples/server/petstore/haskell-yesod/src/OpenAPIPetstore/Types.hs @@ -130,42 +130,42 @@ removeFieldLabelPrefix forParsing prefix = where replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars) specialChars = - [ ("@", "'At") - , ("\\", "'Back_Slash") - , ("<=", "'Less_Than_Or_Equal_To") - , ("\"", "'Double_Quote") - , ("[", "'Left_Square_Bracket") - , ("]", "'Right_Square_Bracket") + [ ("$", "'Dollar") , ("^", "'Caret") - , ("_", "'Underscore") - , ("`", "'Backtick") - , ("!", "'Exclamation") - , ("#", "'Hash") - , ("$", "'Dollar") - , ("%", "'Percent") - , ("&", "'Ampersand") - , ("'", "'Quote") - , ("(", "'Left_Parenthesis") - , (")", "'Right_Parenthesis") + , ("|", "'Pipe") + , ("=", "'Equal") , ("*", "'Star") - , ("+", "'Plus") - , (",", "'Comma") , ("-", "'Dash") - , (".", "'Period") - , ("/", "'Slash") + , ("&", "'Ampersand") + , ("%", "'Percent") + , ("#", "'Hash") + , ("@", "'At") + , ("!", "'Exclamation") + , ("+", "'Plus") , (":", "'Colon") , (";", "'Semicolon") - , ("{", "'Left_Curly_Bracket") - , ("|", "'Pipe") + , (">", "'GreaterThan") , ("<", "'LessThan") - , ("!=", "'Not_Equal") - , ("=", "'Equal") + , (".", "'Period") + , ("_", "'Underscore") + , ("?", "'Question_Mark") + , (",", "'Comma") + , ("'", "'Quote") + , ("/", "'Slash") + , ("(", "'Left_Parenthesis") + , (")", "'Right_Parenthesis") + , ("{", "'Left_Curly_Bracket") , ("}", "'Right_Curly_Bracket") - , (">", "'GreaterThan") + , ("[", "'Left_Square_Bracket") + , ("]", "'Right_Square_Bracket") , ("~", "'Tilde") - , ("?", "'Question_Mark") + , ("`", "'Backtick") + , ("<=", "'Less_Than_Or_Equal_To") , (">=", "'Greater_Than_Or_Equal_To") + , ("!=", "'Not_Equal") , ("~=", "'Tilde_Equal") + , ("\\", "'Back_Slash") + , ("\"", "'Double_Quote") ] mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack replacer =