Skip to content

Add examples for SQL Swagger#954

Merged
veronicagg merged 15 commits intoAzure:masterfrom
nathannfan:master_examples
Feb 24, 2017
Merged

Add examples for SQL Swagger#954
veronicagg merged 15 commits intoAzure:masterfrom
nathannfan:master_examples

Conversation

@nathannfan
Copy link
Copy Markdown
Contributor

This change Updated with examples and appropriate API changes made while validating the API's through Fiddler and the examples through the openAPI validation tools.

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

  • I have read the contribution guidelines.
  • My spec meets the review criteria:
    • The spec conforms to the Swagger 2.0 specification.
    • Validation errors from the Linter extension for VS Code have all been fixed for this spec. (Note: for large, previously checked in specs, there will likely be many errors shown. Please contact our team so we can set a timeframe for fixing these errors if your PR is not going to address them).
    • The spec follows the patterns described in the Swagger good patterns document unless the service API makes this impossible.

Copy link
Copy Markdown
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

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

@nathannfan thanks for adding these examples! I left some comments inline.
There looks to be some APIs that don't have examples associated with them, is that intentional on your end?
Additionally, Our linter/rule validation is throwing some warnings you may want to take a look at https://travis-ci.org/Azure/azure-rest-api-specs/jobs/204330238#L2368 . For the OperationsAPIImplementationValidation, here's an example of what's expected: https://github.com/Azure/azure-rest-api-specs/blob/master/arm-cdn/2016-10-02/swagger/cdn.json#L1578

}
},
"definitions": {
"AsyncOperationResponse": {
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.

This definition is not being used, if not needed, it should be removed from the file.

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.

}
},
"definitions": {
"AsyncOperationResponse": {
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.

This definition is not referred from this file.

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.

"currentServiceObjectiveId": "f1173c43-91bd-4aaa-973c-54e79e15235b",
"requestedServiceObjectiveId": "f1173c43-91bd-4aaa-973c-54e79e15235b",
"requestedServiceObjectiveName": "S0",
"sampleName": null,
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.

Is there a reason why you included this property with null value in the request body? The property doesn't seem to be required, and if that's correct and you remove the null properties from the request body, the errors REQUEST_VALIDATION_ERROR reported by the tool should go away: https://travis-ci.org/Azure/azure-rest-api-specs/jobs/204330240#L2507

Copy link
Copy Markdown
Contributor Author

@nathannfan nathannfan Feb 23, 2017

Choose a reason for hiding this comment

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

I may or may not have taken "every parameter specified" too literally and used response bodies to generate request bodies.

Removed null request parameters.

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.

Can you change the Max sample to specify sampleName?

}
}
},
"202": {
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 this information is not useful to the user and the decision is to not include it in the swagger file, then it should also be removed from here. Do you expect the body on this response to be removed from the service API?

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.

I don't expect it to be removed from the Service API before we go GA with what we have here. I can remove it from examples.

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 the swagger is not doing to define a body for this error code, then the body should be removed from the example https://travis-ci.org/Azure/azure-rest-api-specs/jobs/204765825#L2611

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.

Good point. Removed from examples.

…itr example.

Also updated descriptions of existing restore related db properties.
Copy link
Copy Markdown
Contributor

@anudeepsharma anudeepsharma left a comment

Choose a reason for hiding this comment

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

I see that there are usually 2 create examples one min and one max with more properties like ID, location, kind, type, name etc. Only location and kind are required for SQL Server, for all other resources none of these are settable and should be removed from examples. Getting 2 names from body and path is source of bugs for users, same is true for other parameters as well.

"firewallRuleName": "firewallrulecrudtest-5370",
"api-version": "2014-04-01",
"parameters": {
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/firewallrulecrudtest-12/providers/Microsoft.Sql/servers/firewallrulecrudtest-6285/firewallRules/firewallrulecrudtest-3927",
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.

properties id, location and kind are being ignored, and marked as read only for Firewall, you can remove this as this has no effect on the creation of firewall, also then I think there won't be 2 variants of this for min and max.

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.

Done.

"elasticPoolName": "sqlcrudtest-8102",
"api-version": "2014-04-01",
"parameters": {
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-2369/providers/Microsoft.Sql/servers/sqlcrudtest-8069/elasticPools/sqlcrudtest-8102",
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.

from creates remove ID, name, location (remove for child resource only), kind, type for resources. We should not encourage users to send these values in. I have not cross checked if in swagger these are marked as readonly or not. These should be marked readonly, so that we don't generate setter for the same and don't send these across network

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.

Done, and confirmed they are marked read-only.

"firewallRuleName": "firewallrulecrudtest-3927",
"api-version": "2014-04-01",
"parameters": {
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/firewallrulecrudtest-12/providers/Microsoft.Sql/servers/firewallrulecrudtest-6285/firewallRules/firewallrulecrudtest-3927",
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.

take care of removing id, location, kind, type etc.

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.

Done in all examples from the requests.

@nathannfan
Copy link
Copy Markdown
Contributor Author

Discussed with @veronicagg offline - the source of the warnings from the linter were here before this checkin, and mostly apply to API changes. Since this PR is just for examples, I plan to ignore these for now.

"Name": {
"readOnly": true,
"type": "string",
"description": "The name of the Azure SQL database being upgraded."
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.

this description seems wrong

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 this definition, as it wasn't being used.

"Name": {
"readOnly": true,
"type": "string",
"description": "The name of the Azure SQL Recommended Elastic Pool being upgraded."
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.

description sounds wrong

@jaredmoo
Copy link
Copy Markdown
Contributor

Can we say that upgradeHint is legacy? From the description I don't really understand what it does. If it's legacy then I can just feel happy not thinking about it.

@nathannfan
Copy link
Copy Markdown
Contributor Author

upgradeHint is not showing up in the DatabaseProperties - it seems to have been removed from the API. Removing from databaseProperties.

},
"responses": {
"202": {
"body": {
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 we're not defining this body in the swagger, because it wasn't useful to the user, we can remove the body from here and will avoid https://travis-ci.org/Azure/azure-rest-api-specs/jobs/204765825#L2578

}
}
},
"202": {
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 the swagger is not doing to define a body for this error code, then the body should be removed from the example https://travis-ci.org/Azure/azure-rest-api-specs/jobs/204765825#L2611

}
},
"202": {
"body": {
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.

body should be removed from the example is decision is not to model it in the swagger file.

}
},
"202": {
"body": {
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.

body should be removed from the example is decision is not to model it in the swagger file.

},
"202": {
"body": {
"operation": "CreateDatabaseAsCopy",
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.

body should be removed from the example is decision is not to model it in the swagger file.

}
},
"202": {
"body": {
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.

body should be removed from the example is decision is not to model it in the swagger file.

}
},
"202": {
"body": {
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.


}
},
"202": {
"body": {
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.

body should be removed from the example is decision is not to model it in the swagger file.

}
}
},
"responses": {
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.

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.

Done

}
}
},
"/providers/Microsoft.Sql/operations": {
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.

is this API documented? works? it looks like each of the swagger files include the same api "/providers/Microsoft.Sql/operations", shouldn't it be different for firewallRules.json, replicationLinks.json, and sql.core.json?

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.

They're all under the Microsoft.Sql provider, so calling this actually lists all of them. I just confirmed this in Fiddler. Is there a way to define it in one place and reference it from all files?

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.

I don't think we have a way to reference the operation from one place, so if it lists all the operations and work, the generated SDK code will include the API on each client.

@AutorestCI
Copy link
Copy Markdown

@AutorestCI
Copy link
Copy Markdown

No modification for NodeJS

@AutorestCI
Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants