mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
Use LinkedHashMap for deterministic iteration order (#12230)
* to LinkedHashMap * LinkedHashMap * allModels to LinkedHaskMap Co-authored-by: yilinwang <linda.yilin@gmail.com>
This commit is contained in:
parent
5441aeca72
commit
4ee5f72214
@ -225,7 +225,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
// How to encode special characters like $
|
// How to encode special characters like $
|
||||||
// They are translated to words like "Dollar" and prefixed with '
|
// They are translated to words like "Dollar" and prefixed with '
|
||||||
// Then translated back during JSON encoding and decoding
|
// Then translated back during JSON encoding and decoding
|
||||||
protected Map<String, String> specialCharReplacements = new HashMap<>();
|
protected Map<String, String> specialCharReplacements = new LinkedHashMap<>();
|
||||||
// When a model is an alias for a simple type
|
// When a model is an alias for a simple type
|
||||||
protected Map<String, String> typeAliases = null;
|
protected Map<String, String> typeAliases = null;
|
||||||
protected Boolean prependFormOrBodyParameters = false;
|
protected Boolean prependFormOrBodyParameters = false;
|
||||||
@ -512,7 +512,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
* @return map of all models indexed by names
|
* @return map of all models indexed by names
|
||||||
*/
|
*/
|
||||||
public Map<String, CodegenModel> getAllModels(Map<String, ModelsMap> objs) {
|
public Map<String, CodegenModel> getAllModels(Map<String, ModelsMap> objs) {
|
||||||
Map<String, CodegenModel> allModels = new HashMap<>();
|
Map<String, CodegenModel> allModels = new LinkedHashMap<>();
|
||||||
for (Entry<String, ModelsMap> entry : objs.entrySet()) {
|
for (Entry<String, ModelsMap> entry : objs.entrySet()) {
|
||||||
String modelName = toModelName(entry.getKey());
|
String modelName = toModelName(entry.getKey());
|
||||||
List<ModelMap> models = entry.getValue().getModels();
|
List<ModelMap> models = entry.getValue().getModels();
|
||||||
|
@ -12,21 +12,18 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package openapitools;
|
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/cat_all_of.proto";
|
||||||
import public "models/dog_all_of.proto";
|
import public "models/dog_all_of.proto";
|
||||||
|
import public "models/lizard_all_of.proto";
|
||||||
|
|
||||||
message Pet {
|
message Pet {
|
||||||
|
|
||||||
string petType = 140636936;
|
string petType = 140636936;
|
||||||
|
|
||||||
bool hasLegs = 159828448;
|
|
||||||
|
|
||||||
bool lovesRocks = 499337491;
|
|
||||||
|
|
||||||
string name = 3373707;
|
string name = 3373707;
|
||||||
|
|
||||||
string bark = 3016376;
|
string bark = 3016376;
|
||||||
|
|
||||||
|
bool lovesRocks = 499337491;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ namespace Org.OpenAPITools.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataContract]
|
[DataContract]
|
||||||
[JsonConverter(typeof(JsonSubtypes), "className")]
|
[JsonConverter(typeof(JsonSubtypes), "className")]
|
||||||
[JsonSubtypes.KnownSubType(typeof(Dog), "Dog")]
|
|
||||||
[JsonSubtypes.KnownSubType(typeof(Cat), "Cat")]
|
[JsonSubtypes.KnownSubType(typeof(Cat), "Cat")]
|
||||||
|
[JsonSubtypes.KnownSubType(typeof(Dog), "Dog")]
|
||||||
public partial class Animal : IEquatable<Animal>, IValidatableObject
|
public partial class Animal : IEquatable<Animal>, IValidatableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -46,9 +46,9 @@ class Animal(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
discriminator_value_class_map = {
|
discriminator_value_class_map = {
|
||||||
'Dog': 'Dog',
|
'BigCat': 'BigCat',
|
||||||
'Cat': 'Cat',
|
'Cat': 'Cat',
|
||||||
'BigCat': 'BigCat'
|
'Dog': 'Dog'
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
||||||
|
@ -46,9 +46,9 @@ class Animal(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
discriminator_value_class_map = {
|
discriminator_value_class_map = {
|
||||||
'Dog': 'Dog',
|
'BigCat': 'BigCat',
|
||||||
'Cat': 'Cat',
|
'Cat': 'Cat',
|
||||||
'BigCat': 'BigCat'
|
'Dog': 'Dog'
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
||||||
|
@ -46,9 +46,9 @@ class Animal(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
discriminator_value_class_map = {
|
discriminator_value_class_map = {
|
||||||
'Dog': 'Dog',
|
'BigCat': 'BigCat',
|
||||||
'Cat': 'Cat',
|
'Cat': 'Cat',
|
||||||
'BigCat': 'BigCat'
|
'Dog': 'Dog'
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
||||||
|
@ -46,8 +46,8 @@ class Animal(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
discriminator_value_class_map = {
|
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
|
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
||||||
|
@ -160,42 +160,42 @@ removeFieldLabelPrefix forParsing prefix =
|
|||||||
where
|
where
|
||||||
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
|
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
|
||||||
specialChars =
|
specialChars =
|
||||||
[ ("@", "'At")
|
[ ("$", "'Dollar")
|
||||||
, ("\\", "'Back_Slash")
|
|
||||||
, ("<=", "'Less_Than_Or_Equal_To")
|
|
||||||
, ("\"", "'Double_Quote")
|
|
||||||
, ("[", "'Left_Square_Bracket")
|
|
||||||
, ("]", "'Right_Square_Bracket")
|
|
||||||
, ("^", "'Caret")
|
, ("^", "'Caret")
|
||||||
, ("_", "'Underscore")
|
, ("|", "'Pipe")
|
||||||
, ("`", "'Backtick")
|
, ("=", "'Equal")
|
||||||
, ("!", "'Exclamation")
|
|
||||||
, ("#", "'Hash")
|
|
||||||
, ("$", "'Dollar")
|
|
||||||
, ("%", "'Percent")
|
|
||||||
, ("&", "'Ampersand")
|
|
||||||
, ("'", "'Quote")
|
|
||||||
, ("(", "'Left_Parenthesis")
|
|
||||||
, (")", "'Right_Parenthesis")
|
|
||||||
, ("*", "'Star")
|
, ("*", "'Star")
|
||||||
, ("+", "'Plus")
|
|
||||||
, (",", "'Comma")
|
|
||||||
, ("-", "'Dash")
|
, ("-", "'Dash")
|
||||||
, (".", "'Period")
|
, ("&", "'Ampersand")
|
||||||
, ("/", "'Slash")
|
, ("%", "'Percent")
|
||||||
|
, ("#", "'Hash")
|
||||||
|
, ("@", "'At")
|
||||||
|
, ("!", "'Exclamation")
|
||||||
|
, ("+", "'Plus")
|
||||||
, (":", "'Colon")
|
, (":", "'Colon")
|
||||||
, (";", "'Semicolon")
|
, (";", "'Semicolon")
|
||||||
, ("{", "'Left_Curly_Bracket")
|
|
||||||
, ("|", "'Pipe")
|
|
||||||
, ("<", "'LessThan")
|
|
||||||
, ("!=", "'Not_Equal")
|
|
||||||
, ("=", "'Equal")
|
|
||||||
, ("}", "'Right_Curly_Bracket")
|
|
||||||
, (">", "'GreaterThan")
|
, (">", "'GreaterThan")
|
||||||
, ("~", "'Tilde")
|
, ("<", "'LessThan")
|
||||||
|
, (".", "'Period")
|
||||||
|
, ("_", "'Underscore")
|
||||||
, ("?", "'Question_Mark")
|
, ("?", "'Question_Mark")
|
||||||
|
, (",", "'Comma")
|
||||||
|
, ("'", "'Quote")
|
||||||
|
, ("/", "'Slash")
|
||||||
|
, ("(", "'Left_Parenthesis")
|
||||||
|
, (")", "'Right_Parenthesis")
|
||||||
|
, ("{", "'Left_Curly_Bracket")
|
||||||
|
, ("}", "'Right_Curly_Bracket")
|
||||||
|
, ("[", "'Left_Square_Bracket")
|
||||||
|
, ("]", "'Right_Square_Bracket")
|
||||||
|
, ("~", "'Tilde")
|
||||||
|
, ("`", "'Backtick")
|
||||||
|
, ("<=", "'Less_Than_Or_Equal_To")
|
||||||
, (">=", "'Greater_Than_Or_Equal_To")
|
, (">=", "'Greater_Than_Or_Equal_To")
|
||||||
|
, ("!=", "'Not_Equal")
|
||||||
, ("~=", "'Tilde_Equal")
|
, ("~=", "'Tilde_Equal")
|
||||||
|
, ("\\", "'Back_Slash")
|
||||||
|
, ("\"", "'Double_Quote")
|
||||||
]
|
]
|
||||||
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
||||||
replacer =
|
replacer =
|
||||||
|
@ -130,42 +130,42 @@ removeFieldLabelPrefix forParsing prefix =
|
|||||||
where
|
where
|
||||||
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
|
replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars)
|
||||||
specialChars =
|
specialChars =
|
||||||
[ ("@", "'At")
|
[ ("$", "'Dollar")
|
||||||
, ("\\", "'Back_Slash")
|
|
||||||
, ("<=", "'Less_Than_Or_Equal_To")
|
|
||||||
, ("\"", "'Double_Quote")
|
|
||||||
, ("[", "'Left_Square_Bracket")
|
|
||||||
, ("]", "'Right_Square_Bracket")
|
|
||||||
, ("^", "'Caret")
|
, ("^", "'Caret")
|
||||||
, ("_", "'Underscore")
|
, ("|", "'Pipe")
|
||||||
, ("`", "'Backtick")
|
, ("=", "'Equal")
|
||||||
, ("!", "'Exclamation")
|
|
||||||
, ("#", "'Hash")
|
|
||||||
, ("$", "'Dollar")
|
|
||||||
, ("%", "'Percent")
|
|
||||||
, ("&", "'Ampersand")
|
|
||||||
, ("'", "'Quote")
|
|
||||||
, ("(", "'Left_Parenthesis")
|
|
||||||
, (")", "'Right_Parenthesis")
|
|
||||||
, ("*", "'Star")
|
, ("*", "'Star")
|
||||||
, ("+", "'Plus")
|
|
||||||
, (",", "'Comma")
|
|
||||||
, ("-", "'Dash")
|
, ("-", "'Dash")
|
||||||
, (".", "'Period")
|
, ("&", "'Ampersand")
|
||||||
, ("/", "'Slash")
|
, ("%", "'Percent")
|
||||||
|
, ("#", "'Hash")
|
||||||
|
, ("@", "'At")
|
||||||
|
, ("!", "'Exclamation")
|
||||||
|
, ("+", "'Plus")
|
||||||
, (":", "'Colon")
|
, (":", "'Colon")
|
||||||
, (";", "'Semicolon")
|
, (";", "'Semicolon")
|
||||||
, ("{", "'Left_Curly_Bracket")
|
|
||||||
, ("|", "'Pipe")
|
|
||||||
, ("<", "'LessThan")
|
|
||||||
, ("!=", "'Not_Equal")
|
|
||||||
, ("=", "'Equal")
|
|
||||||
, ("}", "'Right_Curly_Bracket")
|
|
||||||
, (">", "'GreaterThan")
|
, (">", "'GreaterThan")
|
||||||
, ("~", "'Tilde")
|
, ("<", "'LessThan")
|
||||||
|
, (".", "'Period")
|
||||||
|
, ("_", "'Underscore")
|
||||||
, ("?", "'Question_Mark")
|
, ("?", "'Question_Mark")
|
||||||
|
, (",", "'Comma")
|
||||||
|
, ("'", "'Quote")
|
||||||
|
, ("/", "'Slash")
|
||||||
|
, ("(", "'Left_Parenthesis")
|
||||||
|
, (")", "'Right_Parenthesis")
|
||||||
|
, ("{", "'Left_Curly_Bracket")
|
||||||
|
, ("}", "'Right_Curly_Bracket")
|
||||||
|
, ("[", "'Left_Square_Bracket")
|
||||||
|
, ("]", "'Right_Square_Bracket")
|
||||||
|
, ("~", "'Tilde")
|
||||||
|
, ("`", "'Backtick")
|
||||||
|
, ("<=", "'Less_Than_Or_Equal_To")
|
||||||
, (">=", "'Greater_Than_Or_Equal_To")
|
, (">=", "'Greater_Than_Or_Equal_To")
|
||||||
|
, ("!=", "'Not_Equal")
|
||||||
, ("~=", "'Tilde_Equal")
|
, ("~=", "'Tilde_Equal")
|
||||||
|
, ("\\", "'Back_Slash")
|
||||||
|
, ("\"", "'Double_Quote")
|
||||||
]
|
]
|
||||||
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
||||||
replacer =
|
replacer =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user