Skip to content

Commit

Permalink
Merge branch 'master' into issue-10125
Browse files Browse the repository at this point in the history
  • Loading branch information
akshpan authored Apr 14, 2020
2 parents d350261 + fd7e6d8 commit 682cf01
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CodegenModel {

public Set<String> imports = new TreeSet<String>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren;
public CodegenProperty parentContainer;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocs externalDocs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class CodegenProperty implements Cloneable {
public List<String> _enum;
public Map<String, Object> allowableValues;
public CodegenProperty items;
public Integer itemsDepth;
public Map<String, Object> vendorExtensions;
public boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
public boolean isInherited;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,24 @@ public String getterAndSetterCapitalize(String name) {
* @return Codegen Property object
*/
public CodegenProperty fromProperty(String name, Property p) {
return fromProperty(name, p, null);
}
/**
* Convert Swagger Property object to Codegen Property object
*
* @param name name of the property
* @param p Swagger property object
* @param itemsDepth the depth in nested containers or null
* @return Codegen Property object
*/
private CodegenProperty fromProperty(String name, Property p, Integer itemsDepth) {
if (p == null) {
LOGGER.error("unexpected missing property for name " + name);
return null;
}

CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.itemsDepth = itemsDepth;
property.name = toVarName(name);
property.baseName = name;
property.nameInCamelCase = camelize(property.name, false);
Expand Down Expand Up @@ -1873,7 +1885,8 @@ public CodegenProperty fromProperty(String name, Property p) {
if (itemName == null) {
itemName = property.name;
}
CodegenProperty cp = fromProperty(itemName, ap.getItems());
CodegenProperty cp = fromProperty(itemName, ap.getItems(),
itemsDepth == null ? 1 : itemsDepth.intValue() + 1);
updatePropertyForArray(property, cp);
} else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
Expand All @@ -1886,7 +1899,8 @@ public CodegenProperty fromProperty(String name, Property p) {
property.maxItems = ap.getMaxProperties();

// handle inner property
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties());
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties(),
itemsDepth == null ? 1 : itemsDepth.intValue() + 1);
updatePropertyForMap(property, cp);
} else {
setNonArrayMapProperty(property, type);
Expand Down Expand Up @@ -3090,10 +3104,10 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
}

private void addParentContainer(CodegenModel m, String name, Property property) {
final CodegenProperty tmp = fromProperty(name, property);
addImport(m, tmp.complexType);
m.parentContainer = fromProperty(name, property);
addImport(m, m.parentContainer.complexType);
m.parent = toInstantiationType(property);
final String containerType = tmp.containerType;
final String containerType = m.parentContainer.containerType;
final String instantiationType = instantiationTypes.get(containerType);
if (instantiationType != null) {
addImport(m, instantiationType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source 'https://rubygems.org'
gemspec

group :development, :test do
gem 'rake', '~> 12.0.0'
gem 'rake', '~> 12.3.3'
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@types/request": "*"
},
"devDependencies": {
"typescript": "^2.4.2"
"typescript": "^2.4.2",
"minimist": "^1.2.5"
}{{#npmRepository}},
"publishConfig":{
"registry":"{{npmRepository}}"
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source 'https://rubygems.org'
gemspec

group :development, :test do
gem 'rake', '~> 12.0.0'
gem 'rake', '~> 12.3.3'
end
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source 'https://rubygems.org'
gemspec

group :development, :test do
gem 'rake', '~> 12.0.0'
gem 'rake', '~> 12.3.3'
end
4 changes: 2 additions & 2 deletions samples/client/petstore/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GEM
hashdiff (0.3.4)
json (2.1.0)
public_suffix (2.0.5)
rake (12.0.0)
rake (12.3.3)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
Expand Down Expand Up @@ -60,7 +60,7 @@ DEPENDENCIES
autotest-growl (~> 0.2, >= 0.2.16)
autotest-rails-pure (~> 4.1, >= 4.1.2)
petstore!
rake (~> 12.0.0)
rake (~> 12.3.3)
rspec (~> 3.6, >= 3.6.0)
vcr (~> 3.0, >= 3.0.1)
webmock (~> 1.24, >= 1.24.3)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3-SNAPSHOT
2.4.14-SNAPSHOT
40 changes: 20 additions & 20 deletions samples/client/petstore/typescript-node/npm/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,35 +193,35 @@ export declare class PetApi {
setDefaultAuthentication(auth: Authentication): void;
setApiKey(key: PetApiApiKeys, value: string): void;
accessToken: string;
addPet(body: Pet): Promise<{
addPet(body: Pet, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
deletePet(petId: number, apiKey?: string): Promise<{
deletePet(petId: number, apiKey?: string, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>): Promise<{
findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise<{
response: http.ClientResponse;
body: Array<Pet>;
}>;
findPetsByTags(tags: Array<string>): Promise<{
findPetsByTags(tags: Array<string>, options?: any): Promise<{
response: http.ClientResponse;
body: Array<Pet>;
}>;
getPetById(petId: number): Promise<{
getPetById(petId: number, options?: any): Promise<{
response: http.ClientResponse;
body: Pet;
}>;
updatePet(body: Pet): Promise<{
updatePet(body: Pet, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
updatePetWithForm(petId: number, name?: string, status?: string): Promise<{
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
uploadFile(petId: number, additionalMetadata?: string, file?: Buffer): Promise<{
uploadFile(petId: number, additionalMetadata?: string, file?: Buffer, options?: any): Promise<{
response: http.ClientResponse;
body: ApiResponse;
}>;
Expand All @@ -244,21 +244,21 @@ export declare class StoreApi {
setDefaultAuthentication(auth: Authentication): void;
setApiKey(key: StoreApiApiKeys, value: string): void;
accessToken: string;
deleteOrder(orderId: string): Promise<{
deleteOrder(orderId: string, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
getInventory(): Promise<{
getInventory(options?: any): Promise<{
response: http.ClientResponse;
body: {
[key: string]: number;
};
}>;
getOrderById(orderId: number): Promise<{
getOrderById(orderId: number, options?: any): Promise<{
response: http.ClientResponse;
body: Order;
}>;
placeOrder(body: Order): Promise<{
placeOrder(body: Order, options?: any): Promise<{
response: http.ClientResponse;
body: Order;
}>;
Expand All @@ -281,35 +281,35 @@ export declare class UserApi {
setDefaultAuthentication(auth: Authentication): void;
setApiKey(key: UserApiApiKeys, value: string): void;
accessToken: string;
createUser(body: User): Promise<{
createUser(body: User, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
createUsersWithArrayInput(body: Array<User>): Promise<{
createUsersWithArrayInput(body: Array<User>, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
createUsersWithListInput(body: Array<User>): Promise<{
createUsersWithListInput(body: Array<User>, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
deleteUser(username: string): Promise<{
deleteUser(username: string, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
getUserByName(username: string): Promise<{
getUserByName(username: string, options?: any): Promise<{
response: http.ClientResponse;
body: User;
}>;
loginUser(username: string, password: string): Promise<{
loginUser(username: string, password: string, options?: any): Promise<{
response: http.ClientResponse;
body: string;
}>;
logoutUser(): Promise<{
logoutUser(options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
updateUser(username: string, body: User): Promise<{
updateUser(username: string, body: User, options?: any): Promise<{
response: http.ClientResponse;
body?: any;
}>;
Expand Down
Loading

0 comments on commit 682cf01

Please sign in to comment.