Google Cloud Endpoints REST Discovery Document missing format - ios

I've upgraded to Cloud Endpoints 2.0 which no longer supports RPC. Therefore, I generated a new discovery document and used the service generator with the REST discovery doc as input in order to generate the client library for my iOS app.
Using the new REST discovery doc I am getting the following error when trying to generate the library:
~/workspace/google-api-objectivec-client-for-rest/Source/Tools/ServiceGenerator/build/Release/ServiceGenerator discovery/servUsApi-v1-rest.discovery --outputDir GTLAPI --gtlrFrameworkName GoogleAPIClientForREST
ERROR: Failure, exception: Looking at parameter 'creditKickbackKash:creditAmount', found a type/format pair of 'number/(null)', and don't how to map that to Objective-C
I was able to manually fix this by adding (in numerous places) in the discovery doc, the "format": "double" key and value for all double parameters. Notice creditAmount below is missing a format, like all other doubles.
The generated discovery doc looks like this:
"creditKickbackKash": {
"httpMethod": "PUT",
"id": "servUsApi.admin.creditKickbackKash",
"parameterOrder": [
"userId",
"creditAmount"
],
"parameters": {
"userId": {
"format": "int64",
"location": "path",
"required": true,
"type": "string"
},
"creditAmount": {
"location": "path",
"required": true,
"type": "number"
}
},
"path": "creditKickbackKash/{userId}/{creditAmount}",
"response": {
"$ref": "ResultDTO"
},
"scopes": [
"https://www.googleapis.com/auth/userinfo.email"
]
}
Is anyone else having this issue? How can I get the discovery document generation to properly format the document including double number types?

I had the same problem. I rolled back from 1.9.50 to 1.9.48 and the problem is gone.

Related

How to fix 403 error when creating GoogleFit datasource

I am using GoogleFit Rest API to create a nutrition data source so that I can subsequently store nutrition information. I have done this successfully on Android via the GoogleFit SDK, but because no such SDK is available on iOS, I resorted to using the REST APIs via the link above. When trying to create the data source I am returned the following error:
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"errors": [
{
"message": "The caller does not have permission",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
and the POST request I am using is:
Endpoint: https://www.googleapis.com/fitness/v1/users/me/dataSources
Body:
{
"application": {
"detailsUrl": "https://strongfoundation.dev",
"name": "Strong Foundation",
"packageName": "com.coding.casa.Strong.Foundation",
"version": "1.0.1"
},
"dataStreamId": "raw:com.google.nutrition:com.coding.casa.Strong.Foundation:Apple:iPad Air (3rd generation):****",
"dataType": {
"name": "com.google.nutrition"
},
"device": {
"manufacturer": "Apple",
"model": "iPad Air (3rd generation)",
"type": "phone",
"uid": "*****",
"version": "15.7"
},
"name": "strong-foundation-food",
"type": "raw"
}
Has anyone seen this error and was able to resolve it? I have tried adding the API Key to the request, but that did not change the error, and I do have the Fitness API enabled on my project.
EDIT:
I am also supplying a Bearer token with the following authorized scopes
"https://www.googleapis.com/auth/fitness.activity.read",
"https://www.googleapis.com/auth/fitness.body.write",
"https://www.googleapis.com/auth/fitness.body.read",
"https://www.googleapis.com/auth/fitness.nutrition.read",
"https://www.googleapis.com/auth/fitness.nutrition.write",
You don't include the others details of the REST method call.
Importantly, HTTP 403 is Forbidden suggesting that you didn't include an Authorization header in your request with value Bearer {TOKEN} where {TOKEN} is an access token for an identity that has suitable scopes to access the API. See authorization
Although Swift is not one of Google's officially supported languages, Google has a Swift REST Client Generator for Google APIs and you should be able to use it to generate a Google client library for Swift for Google Fit.
Did some more playing around with the FitnessAPI (specifically creating data sources) and found the issues was with my request payload.
The payload that worked for me is as follows:
{
"application": {
"detailsUrl": "https://strongfoundation.dev",
"name": "Strong Foundation",
"version": "1.0.1"
},
"dataType": {
"name": "com.google.nutrition"
},
"device": {
"manufacturer": "Apple",
"model": "iPad Air (3rd generation)",
"type": "phone",
"uid": "****",
"version": "15.7"
},
"name": "strong-foundation-food",
"type": "raw"
}
The deltas from the original one are removed the following properties:
application.packageName
dataStreamId

Graph REST API - Search inside DriveItem not working for non-mainstream file extensions

I've been trying to search within a specific DriveItem folder but I've been having some troubles. First of all, despite the API stating that "You can search within a folder hierarchy, a whole drive, or files shared with the current user.", I haven't found any documentation supporting this. I have found this stackoverflow reply that describes how to do it. Unfortunately, it doesn't to be working very well.
Since I don't know how sensitive IDs are, I'll be redacting them in my examples.
https://graph.microsoft.com/v1.0/me/drive/items/<id_parent_folder>/children?select=name
This request returns all files inside the folder I want to search and it does list everything inside the folder. The response is something like:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('<id_user>')/drive/items('<id_parent_folder>')/children(name)",
"value": [
{
"#odata.etag": "\"{redacted1},1\"",
"name": "automation_csv.csv"
},
{
"#odata.etag": "\"{redacted2},1\"",
"name": "HOSPITAIS_PT.cpg"
},
{
"#odata.etag": "\"{redacted3},1\"",
"name": "HOSPITAIS_PT.dbf"
},
{
"#odata.etag": "\"{redacted4},1\"",
"name": "HOSPITAIS_PT.prj"
},
{
"#odata.etag": "\"{redacted5},1\"",
"name": "HOSPITAIS_PT.qpj"
},
{
"#odata.etag": "\"{redacted6},1\"",
"name": "HOSPITAIS_PT.shp"
},
{
"#odata.etag": "\"{redacted7},1\"",
"name": "HOSPITAIS_PT.shx"
}
]
}
However, when searching inside the folder I only get the CSV file....
https://graph.microsoft.com/v1.0/me/drive/items/<id_parent_folder>/search(q='')?select=name
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
"value": [
{
"#odata.type": "#microsoft.graph.driveItem",
"name": "<name_parent_folder>"
},
{
"#odata.type": "#microsoft.graph.driveItem",
"name": "automation_csv.csv"
}
]
}
Searching for any other file name produces no results.
Is this a bug or a feature? Is there another endpoint that allows me to search all files inside a folder?
EDIT: changed the "beta" endpoint to "v1.0", though they produce the same results. Just don't want to create the assumption that it only happens in the beta endpoint.
Use the Microsoft Query API to search instead of using q search parameter.
See https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-beta

Swagger: query params on POST methods not allowed?

I've got a POST endpoint described in Swagger and I want that endpoint to also have query parameters. We're using 1.2 swagger format because, well, legacy reasons. We use 3scale, it hosts the documents and you edit your swagger in their web UI. However, when I try to save the document it gives me the following error.
JSON Spec can not have paramType='body' and paramType='query' on the same method
I can't find anything in the swagger specs that says this is an actual limitation. Is this likely something specific to 3Scale or is this a general swagger limitation? And if the latter, can someone point me at a spec is that clarifies it?
The actual REST endpoint doesn't care, it's happy with query params on a POST. It's just getting the Swagger tool to be happy. Here's the abbreviated snippet of the swagger doc:
{
"parameters": [
{
"name": "myQueryParam",
"dataType": "string",
"paramType": "query",
"required": true
},
{
"name": "body",
"dataType": "string",
"paramType": "body",
"required": true
}
],
"httpMethod": "POST"
}
not sure if the error message is a generic validation error, but there a couple of error in the specification you shared:
it is "method" and not "httpMethod"
it is "type" and not "dataType"
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/1.2.md
The following example works for me, but I use required=false:
{
"in": "query",
"name": "myQueryParam",
"required": false,
"type": "string"
}
See also Swagger parameters in query and/or body

Azure DevOps Extension custom service endopint for ID/KEY

I am developing Azure DevOps extension which contain service endpoint to hold secret ID/KEY. My requirement is to have endpoint just consist of Connection name, ID ,and Key in it.I have gone trough list of provided endpoints in Microsoft but I couldn't find suitable option to satisfy my requirement.
https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=vsts#sep-ssh
closest solution I found is as below . But it contains input box for server URL(Which I need to omit (in this example though I don't define server URL it displays in popup dialog)). Please refer below image.
Is it possible to remove Server URL from above dialog box Or it there better endpoint type I can use for this requirement? please be kind enough to share some light with me.
You'll need to create a custom service type, that will allow you to show/hide the individual text boxes. You can find an example in the Azure DevOps Extension Tasks which I maintain.
You define custom service endpoint types in the vss-extension.json along with your other extension points:
{
"id": "vsts-marketplace-endpoint-type",
"type": "ms.vss-endpoint.service-endpoint-type",
"targets": [
"ms.vss-endpoint.endpoint-types"
],
"properties": {
"name": "VstsMarketplacePublishing",
"displayName": "Visual Studio Marketplace",
"url": {
"displayName": "Marketplace URL",
"value": "https://marketplace.visualstudio.com",
"isVisible": "false"
},
"helpMarkDown": "Required permissions: <ul><li><b>Publish</b>: All accessible organisations, Marketplace (Publish)</li><li><b>Share</b>: All accessible organisations, Marketplace Publish</li><li><b>Install</b>: All accessible organisations or a specific organisation, Extensions (read and manage), Marketplace (acquire)</li><li><b>Query Version</b>: All accessible organisations, Marketplace (read)</li><li><b>Is Valid Extension</b>: All accessible organisations, Marketplace (read)</li></ul><br/><a href='https://www.visualstudio.com/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate'>More information</a>.",
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
"inputDescriptors": [
{
"id": "username",
"name": "Username",
"description": "Username",
"inputMode": "textbox",
"isConfidential": false,
"validation": {
"isRequired": false,
"dataType": "string",
"maxLength": 300
},
"values": {
"inputId": "username",
"isDisabled": true,
"defaultValue": ""
}
},
{
"id": "password",
"name": "Personal access token",
"description": "Azure DevOps personal access token.",
"inputMode": "passwordbox",
"isConfidential": true,
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
}
]
}
]
}
},
You may find other extensions that set or configure the authentication dialog on GitHub, there are quite a few. Useful docs are here in an old blog post.

Dart Services API: how to access the /fixes through the API service?

I am looking at:
https://github.com/dart-lang/dart-services
And am trying to adapt the example given (https://dartpad.dartlang.org/2a7fd9328e0a567ee79b) to pull back information from '/api/dartservices/v1/fixes' rather than '/api/dartservices/v1/analyze'.
Apologies, if I am missing something obvious here but changing the path in the example to:
"https://dart-services.appspot.com/api/dartservices/v1/fixes";
returns an error. Does anyone know how I can get the information from '/api/dartservices/v1/fixes rather than '/api/dartservices/v1/analyze'? Or does anyone have an example of this working?
Thanks.
Sending a POST request to https://dart-services.appspot.com/api/dartservices/v1/fixes with the data the DartPad example sends yields the error message "Missing parameter: 'offset'".
Looking at the discovery doc for the service https://dart-services.appspot.com/api/discovery/v1/apis/dartservices/v1/rest I see both analyze and fixes operations take a SourceRequest:
"SourceRequest": {
"id": "SourceRequest",
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "The Dart source.",
"required": true
},
"offset": {
"type": "integer",
"description": "An optional offset into the source code.",
"format": "int32"
},
"strongMode": {
"type": "boolean",
"description": "An optional signal whether the source should be processed in strong mode"
}
}
offset is not marked as required so maybe there is a bug in the implementation of fixes wrt that parameter.
To make the DartPad example work, change:
Map m = {'source': textArea.value};
to
Map m = {'source': textArea.value, 'offset': 0};

Resources