forked from loafle/openapi-generator-original
added empty var check
This commit is contained in:
parent
530ebe1f7d
commit
9e5576d3fe
@ -11,4 +11,5 @@ public class CodegenModel {
|
||||
public String defaultValue;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public Boolean hasVars, emptyVars;
|
||||
}
|
@ -353,7 +353,8 @@ public class DefaultCodegen {
|
||||
m.imports.add(containerType);
|
||||
}
|
||||
}
|
||||
if(impl.getProperties() != null) {
|
||||
if(impl.getProperties() != null && impl.getProperties().size() > 0) {
|
||||
m.hasVars = true;
|
||||
for(String key: impl.getProperties().keySet()) {
|
||||
Property prop = impl.getProperties().get(key);
|
||||
|
||||
@ -396,6 +397,9 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
m.emptyVars = true;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
@ -3,15 +3,16 @@
|
||||
#import "SWGDate.h"
|
||||
#import "{{classname}}.h"
|
||||
|
||||
@implementation {{classname}}
|
||||
@implementation {{classname}}{{#parent}}: {{parent}}{{/parent}}
|
||||
|
||||
{{#hasVars}}
|
||||
-(id){{#vars}}{{name}}: ({{datatype}}) {{name}}{{^hasMore}} { {{/hasMore}}
|
||||
{{/vars}}
|
||||
{{#vars}}_{{name}} = {{name}};
|
||||
{{/vars}}
|
||||
return self;
|
||||
}
|
||||
|
||||
{{/hasVars}}
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -11,10 +11,11 @@
|
||||
{{#vars}}
|
||||
@property(nonatomic) {{datatype}} {{name}}; {{#description}}/* {{{description}}} {{#isNotRequired}}[optional]{{/isNotRequired}} */{{/description}}{{newline}}
|
||||
{{/vars}}
|
||||
{{#hasVars}}
|
||||
- (id) {{#vars}}{{name}}: ({{datatype}}) {{name}}{{#hasMore}}
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}
|
||||
{{/vars}}
|
||||
{{newline}}
|
||||
{{/hasVars}}
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
{{newline}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user