Skip to content

Commit

Permalink
Yet another fix for lowerCamel field names.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuk committed Sep 27, 2016
1 parent 4f42626 commit 1e9d75b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.api.tools.framework.aspects.documentation.model.DocumentationUtil;
import com.google.api.tools.framework.aspects.documentation.model.ElementDocumentationAttribute;
import com.google.api.tools.framework.model.Field;
import com.google.api.tools.framework.model.FieldSelector;
import com.google.api.tools.framework.model.Interface;
import com.google.api.tools.framework.model.MessageType;
import com.google.api.tools.framework.model.Method;
Expand All @@ -40,6 +41,7 @@
import com.google.api.tools.framework.model.ProtoFile;
import com.google.api.tools.framework.model.TypeRef;
import com.google.api.tools.framework.model.TypeRef.Cardinality;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -115,6 +117,14 @@ public String propertyName(Field field) {
return namer.getVariableName(field);
}

public String fieldSelectorName(FieldSelector fieldSelector) {
ImmutableList.Builder<String> names = ImmutableList.builder();
for (Field field : fieldSelector.getFields()) {
names.add(propertyName(field));
}
return Joiner.on(".").join(names.build());
}

/**
* Return comments lines for a given proto element, extracted directly from the proto doc
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/com/google/api/codegen/nodejs/main.snip
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@
var PAGE_DESCRIPTORS = {
@join method : context.messages.filterPageStreamingMethods(ifaceConfig, context.getSupportedMethods(service)) on {@", "}.add(BREAK)
@let pageStreaming = ifaceConfig.getMethodConfig(method).getPageStreaming(), \
requestToken = pageStreaming.getRequestTokenField().getSimpleName(), \
responseToken = pageStreaming.getResponseTokenField().getSimpleName(), \
resources = pageStreaming.getResourcesField().getSimpleName()
requestToken = context.propertyName(pageStreaming.getRequestTokenField()), \
responseToken = context.propertyName(pageStreaming.getResponseTokenField()), \
resources = context.propertyName(pageStreaming.getResourcesField())
{@methodName(method)}: new gax.PageDescriptor(
'{@requestToken}',
'{@responseToken}',
Expand Down Expand Up @@ -224,11 +224,11 @@
'{@bundling.getBundledField().getSimpleName()}',
[
@join fieldSelector : bundling.getDiscriminatorFields() on {@", "}.add(BREAK)
'{@fieldSelector.getParamName}'
'{@context.fieldSelectorName(fieldSelector)}'
@end
],
@if bundling.hasSubresponseField()
'{@bundling.getSubresponseField().getSimpleName()}',
'{@context.propertyName(bundling.getSubresponseField())}',
@else
null,
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ var CODE_GEN_NAME_VERSION = 'gapic/0.1.0';

var PAGE_DESCRIPTORS = {
listShelves: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'shelves'),
listBooks: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'books'),
listStrings: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'strings'),
findRelatedBooks: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'names')
};

Expand Down Expand Up @@ -116,7 +116,7 @@ function LibraryServiceApi(gaxGrpc, grpcClients, opts) {
'edition',
'shelf.name'
],
'book_names',
'bookNames',
gax.createByteLengthFunction(grpcClients.libraryServiceClient.google.example.library.v1.Book))
};
var defaults = gaxGrpc.constructSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ var CODE_GEN_NAME_VERSION = 'gapic/0.1.0';

var PAGE_DESCRIPTORS = {
listShelves: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'shelves'),
listBooks: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'books'),
listStrings: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'strings'),
findRelatedBooks: new gax.PageDescriptor(
'page_token',
'next_page_token',
'pageToken',
'nextPageToken',
'names')
};

Expand Down Expand Up @@ -116,7 +116,7 @@ function LibraryServiceApi(gaxGrpc, grpcClients, opts) {
'edition',
'shelf.name'
],
'book_names',
'bookNames',
gax.createByteLengthFunction(grpcClients.libraryServiceClient.google.example.library.v1.Book))
};
var defaults = gaxGrpc.constructSettings(
Expand Down

0 comments on commit 1e9d75b

Please sign in to comment.