forked from loafle/openapi-generator-original
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 $
|
||||
// They are translated to words like "Dollar" and prefixed with '
|
||||
// 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
|
||||
protected Map<String, String> typeAliases = null;
|
||||
protected Boolean prependFormOrBodyParameters = false;
|
||||
@ -512,7 +512,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return map of all models indexed by names
|
||||
*/
|
||||
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()) {
|
||||
String modelName = toModelName(entry.getKey());
|
||||
List<ModelMap> models = entry.getValue().getModels();
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ namespace Org.OpenAPITools.Model
|
||||
/// </summary>
|
||||
[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<Animal>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
, ("<", "'LessThan")
|
||||
, ("!=", "'Not_Equal")
|
||||
, ("=", "'Equal")
|
||||
, ("}", "'Right_Curly_Bracket")
|
||||
, (">", "'GreaterThan")
|
||||
, ("~", "'Tilde")
|
||||
, ("<", "'LessThan")
|
||||
, (".", "'Period")
|
||||
, ("_", "'Underscore")
|
||||
, ("?", "'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")
|
||||
, ("!=", "'Not_Equal")
|
||||
, ("~=", "'Tilde_Equal")
|
||||
, ("\\", "'Back_Slash")
|
||||
, ("\"", "'Double_Quote")
|
||||
]
|
||||
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
||||
replacer =
|
||||
|
@ -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")
|
||||
, ("<", "'LessThan")
|
||||
, ("!=", "'Not_Equal")
|
||||
, ("=", "'Equal")
|
||||
, ("}", "'Right_Curly_Bracket")
|
||||
, (">", "'GreaterThan")
|
||||
, ("~", "'Tilde")
|
||||
, ("<", "'LessThan")
|
||||
, (".", "'Period")
|
||||
, ("_", "'Underscore")
|
||||
, ("?", "'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")
|
||||
, ("!=", "'Not_Equal")
|
||||
, ("~=", "'Tilde_Equal")
|
||||
, ("\\", "'Back_Slash")
|
||||
, ("\"", "'Double_Quote")
|
||||
]
|
||||
mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack
|
||||
replacer =
|
||||
|
Loading…
x
Reference in New Issue
Block a user