CHJani / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Enforce Discovery pattern constraint for string parameters #369

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?

http://code.google.com/apis/discovery/v1/reference.html
https://www.googleapis.com/discovery/v1/apis/plus/v1/rest

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?

All

Please describe the feature requested.

Example from Google+ API (though applies to any Google API):

get: {
id: "plus.people.get",
path: "people/{userId}",
httpMethod: "GET",
description: "Get a person's profile.",
parameters: {
userId: {
type: "string",
description: "The ID of the person to get the profile for. The special value 
"me" can be used to indicate the authenticated user.",
required: true,
pattern: "me|[0-9]+",
location: "path"
}
},
parameterOrder: [
"userId"
],
response: {
$ref: "Person"
},
scopes: [
"https://www.googleapis.com/auth/plus.me"
]
},

Note the "pattern" on the "userId" parameter.  This is a 
java.util.regex.Pattern regular expression that is actually enforced by 
Google's servers.  Thus, we should be able to enforce this constraint by 
throwing an IllegalArgumentException if the specified parameter does not match 
the Discovery pattern.

Original issue reported on code.google.com by yan...@google.com on 8 Dec 2011 at 1:48

GoogleCodeExporter commented 9 years ago
We might also want to provide a way to suppress this runtime check.  One use 
case is if there is a bug in the pattern and it is fixed in the server, but the 
user is unable to update to a newer version of the client library.

Original comment by yan...@google.com on 8 Dec 2011 at 2:59

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Mar 2012 at 2:10

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 16 May 2012 at 1:24

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 30 May 2012 at 10:04

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 21 Jun 2012 at 5:45

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 29 Jun 2012 at 2:51

GoogleCodeExporter commented 9 years ago
Almost fixed.  You just missed my second comment: 

"We might also want to provide a way to suppress this runtime check.  One use 
case is if there is a bug in the pattern and it is fixed in the server, but the 
user is unable to update to a newer version of the client library."

Original comment by yan...@google.com on 4 Jul 2012 at 2:29

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/6483062/

Original comment by rmis...@google.com on 28 Aug 2012 at 1:36

GoogleCodeExporter commented 9 years ago
Fixed in the generated libraries.

Original comment by rmis...@google.com on 28 Aug 2012 at 6:54

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 28 Aug 2012 at 6:54