Skip to content

[CognitiveServices] LUIS Runtime API Spec#2051

Merged
fearthecowboy merged 10 commits into
Azure:currentfrom
southworks:cognitiveservices-luis-runtime-spec
Dec 1, 2017
Merged

[CognitiveServices] LUIS Runtime API Spec#2051
fearthecowboy merged 10 commits into
Azure:currentfrom
southworks:cognitiveservices-luis-runtime-spec

Conversation

@pcostantini
Copy link
Copy Markdown
Contributor

@pcostantini pcostantini commented Nov 27, 2017

This PR includes the API Spec for the LUIS Runtime endpoint (Predictions):
https://westus.dev.cognitive.microsoft.com/docs/services/5819c76f40a6350ce09de1ac/operations/5819c77140a63516d81aee78

This checklist is used to make sure that common issues in a pull request are addressed. This will expedite the process of getting your pull request merged and avoid extra work on your part to fix issues discovered during the review process.

PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes.
  • Swagger files are correctly named (e.g. the api-version in the path should match the api-version in the spec).

Quality of Swagger

"hostTemplate": "{AzureRegion}.api.cognitive.microsoft.com",
"parameters": [
{
"$ref": "../../../Common/ExtendedRegions.json#/parameters/AzureRegion"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GA, what is the region list that should be included?
Should the BasicRegion or ExtendedRegion sets be used instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If neither of these fit LUIS' profile, feel free to create your own AzureRegion definitions within the spec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, still awaiting confirmation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcostantini when you've got confirmation, ping and we can merge this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fearthecowboy ,
Just got confirmation, the ExtendedRegions.json is the one to be used, so no further changes are needed.
Thanks!

"/{appId}": {
"get": {
"description": "Gets the published endpoint predictions for the given query.",
"operationId": "Prediction_GetPredictionsFromEndpointViaGet",
Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use operationId to represent the group/method that gets generated for the SDKs.

The format should be <method-group>_<method-name> .

Ideally, something like Predictions_List (and let the description and parameters speak for themselves)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to Predictions_Resolve

},
"entities": {
"type": "array",
"x-nullable": true,
Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you're explicitly marking things x-nullable: true ?

That affects code-generation in some specific ways, but shouldn't be used so liberally without a definite reason.

Most of what you've marked here would be nullable anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all x-nullable: true

},
"post": {
"description": "Gets the published endpoint prediction for the given long query.",
"operationId": "Prediction_GetPredictionsFromEndpointViaPost",
Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any fundamental differences between using the GET and POST endpoints?

again this should be Predictions_List or something. Although, you can't have two methods with the same operation id, so if they are functionally the same, call the GET one Predictions_List2 and call this one Predictions_List and we'll give you the configuration to suppress generating the code for the GET (since the SDK caller won't ever care which one it's using)

If there are fundamental differences between GET and POST , we should examine them and see what we can do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. The API allows using GET or POST, but the end-result is the same and the parameters constraints are the same too.
For the SDK generation the POST can be used instead. Do you have the configuration required to disable an operation? (Please take a look at the current C# generation @ https://github.com/southworkscom/azure-sdk-for-net/blob/cognitiveservices-luis-runtime-sdk/src/SDKs/CognitiveServices/dataPlane/Language/LUIS-Runtime/Generated/PredictionExtensions.cs#L50 )

Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this spec still needs descriptions on all properties, parameters and model classes.

After that, we can generate the code and see if it looks like a usable SDK; after looking at this, I'm not exactly sure what the API is actually supposed to do...

"type": "object",
"properties": {
"query": {
"type": "string",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need description fields on all your properties.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added description to all parameters and attributes

"type": "string"
},
"startIndex": {
"type": "number"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a good idea to have maximum and minimum values for numbers if you can.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added description with their meaning. These values change based on the input. They represent a match within the input query

],
"responses": {
"200": {
"description": "A JSON object containing the predictions.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't describe the payload in terms of encoding or transport, (ie, remove A JSON object containing the ) -- Give a description that describes what the output is. (What exactly is a list of predictions?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated along with entity's description and their attributes

"in": "path",
"type": "string",
"required": true,
"description": "Format - guid. The application ID."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the application ID used for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added description for the Luis Application ID

@pcostantini
Copy link
Copy Markdown
Contributor Author

Hi @fearthecowboy ,
We updated the spec based on your feedback.

Both GET and POST operation are the same... For the SDK Generation, do you have the configuration required to disable an operation?

Thanks!

@azuresdkciprbot
Copy link
Copy Markdown

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/cognitiveservices/data-plane/LUIS/Runtime/readme.md
Before the PR: Warning(s): 0 Error(s): 0
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

## Runtime 2.0
These settings apply only when `--tag=runtime_2_0` is specified on the command line.

``` yaml $(tag) == 'runtime_2_0'
Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this section to this:

``` yaml $(tag) == 'runtime_2_0'
input-file: v2.0/LUIS-Runtime.json

# remove Resolve2 from code-generation (since the POST and GET operations are functionally identical. )
directive:
  remove-operation: Prediction_Resolve2
 
```

It will suppress Resolve2 from getting code generation

"description": "The LUIS application ID (Guid)."
},
{
"name": "q",
Copy link
Copy Markdown
Contributor

@fearthecowboy fearthecowboy Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the q parameters, we should probably add:

           "x-ms-client-name":"query",

in so the parameter name is query rather than q in the generated code (do this on Resolve2 as well, just for completion sake)


### Runtime 2.0 - CSharp Settings
These settings apply only when `--csharp` is specified on the command line.
``` yaml $(csharp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, let's change this (uses new feature!)

csharp:
  override-client-name: LuisRuntimeAPI
  sync-methods: None
  license-header: MICROSOFT_MIT_NO_VERSION
  azure-arm: false
  namespace: Microsoft.Azure.CognitiveServices.Language.LUIS
  output-folder: $(csharp-sdks-folder)/CognitiveServices/dataPlane/Language/LUIS-Runtime/Generated
  clear-output-folder: true

# csharp has support for modelAsExtensible now; replace modelAsString with that. 
directive:
  from: swagger-document
  where: $..['x-ms-enum']
  transform: >
    if( $['modelAsString'] ) {
      $['modelAsExtensible'] = true;
      $['modelAsString'] = false;
    }

@fearthecowboy
Copy link
Copy Markdown
Contributor

@pcostantini

I'm pretty good with this, just a couple minor tweaks that I've provided, and I think we're good-to-go.

  • add x-ms-client-name to query parameter to make a better codegen experience.
  • suppress Resolve2 from being codegen'd
  • tweak the x-ms-enum to switch to modelAsExtensible instead of modelAsString (we have a better means to generate code now for enums that may add items later)

@azuresdkciprbot
Copy link
Copy Markdown

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/cognitiveservices/data-plane/LUIS/Runtime/readme.md
Before the PR: Warning(s): 0 Error(s): 0
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@pcostantini
Copy link
Copy Markdown
Contributor Author

Hi @fearthecowboy ,
Got confirmation about the regions, the current ones are Ok. No more changes from out side =)
Regards,
-PabloC.

@fearthecowboy fearthecowboy merged commit 02fe069 into Azure:current Dec 1, 2017
@AutorestCI
Copy link
Copy Markdown

No modification for AutorestCI/azure-sdk-for-ruby

@AutorestCI
Copy link
Copy Markdown

No modification for AutorestCI/azure-sdk-for-python

@AutorestCI
Copy link
Copy Markdown

No modification for AutorestCI/azure-sdk-for-node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants