Skip to content

SQL Capabilities Swagger#1015

Merged
olydis merged 15 commits intoAzure:masterfrom
nathannfan:master_capabilities
Mar 17, 2017
Merged

SQL Capabilities Swagger#1015
olydis merged 15 commits intoAzure:masterfrom
nathannfan:master_capabilities

Conversation

@nathannfan
Copy link
Contributor

@nathannfan nathannfan commented Mar 9, 2017

Add swagger for SQL capabilities API and refer to it in capabilities.json.

Validate-spec, validate-example, and linter all passing with no issues.

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

  • [x ] The title of the PR is clear and informative.
  • [x ] 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.
  • [x ] 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.
  • [x ] 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
Contributor

@jaredmoo jaredmoo left a comment

Choose a reason for hiding this comment

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

Overall looks good, some minor comments

"Capabilities"
],
"operationId": "Capabilities_Get",
"description": "Returns information about the Azure SQL capabilities available for the specified region.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "information about"

Copy link
Contributor

Choose a reason for hiding this comment

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

And "Azure SQL"

Copy link
Contributor

Choose a reason for hiding this comment

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

also please replace 'region' with 'location' throughout this file, e.g.

"Gets the capabilities available for the specified location."

"in": "path",
"required": true,
"type": "string",
"description": "The Id of the region for which the Azure SQL capabilities are retrieved."
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "Azure SQL"

],
"x-ms-enum": {
"name": "MaxSizeUnits",
"modelAsString": true
Copy link
Contributor

Choose a reason for hiding this comment

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

Can modelAsString be removed? It's unlikely we will go past petabytes in the foreseeable future

],
"x-ms-enum": {
"name": "CapabilityStatus",
"modelAsString": true
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing?

"modelAsString": true
}
},
"status": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can status be extracted as a common definition to reduce duplication?

}
}
},
"description": "Represents the maximum size limits for an Azure SQL Database."
Copy link
Contributor

Choose a reason for hiding this comment

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

"an Azure SQL Database" -> "a database"

"items": {
"$ref": "#/definitions/MaxSizeCapability"
},
"description": "The list of supported maximum Azure SQL Database sizes for this Service Objective."
Copy link
Contributor

Choose a reason for hiding this comment

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

"Azure SQL Database" -> "database"

Copy link
Contributor

Choose a reason for hiding this comment

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

et cetera for other "Azure SQL" in descriptions other than at top of tile

@olydis
Copy link
Contributor

olydis commented Mar 9, 2017

Thanks for providing the example! It seems like one of our validators has uncovered some inconsistencies between the Swagger and the example: https://travis-ci.org/Azure/azure-rest-api-specs/jobs/209204805#L975
Please fix the Swagger or the example accordingly.

@nathannfan
Copy link
Contributor Author

@olydis So we have a lot of errors regarding examples having null not matching the expected data types for our resource definitions. Since this is what the API actually returns, we are including the nulls in the examples, and ignoring the example validation errors for now.

I think it's an open discussion here: #798

@olydis
Copy link
Contributor

olydis commented Mar 9, 2017

@nathannfan oh, I was not aware of that problem! fair enough, I'm okay with ignoring those null-related messages then, but what about https://travis-ci.org/Azure/azure-rest-api-specs/jobs/209204805#L1650?

@olydis
Copy link
Contributor

olydis commented Mar 9, 2017

also, slightly concerned about https://travis-ci.org/Azure/azure-rest-api-specs/jobs/209204805#L2122 (think the Z suffix is missing in order to conform with rfc3339), not sure if our runtime throw up on that!

@jaredmoo
Copy link
Contributor

jaredmoo commented Mar 9, 2017

@olydis the system2 error is fixed in #1005

@nathannfan
Copy link
Contributor Author

@olydis For this https://travis-ci.org/Azure/azure-rest-api-specs/jobs/209204805#L2122, we checked, and the client runtimes handle it as UTC time, which is correct in our API's case, so we also ignore these warnings.

@jaredmoo
Copy link
Contributor

jaredmoo commented Mar 9, 2017

@olydis well spotted, we'll file this as a bug ('Z' issue)

@olydis
Copy link
Contributor

olydis commented Mar 10, 2017

@jaredmoo @nathannfan Excellent, thanks for testing with client runtime!

"Default"
],
"x-ms-enum": {
"name": "CapabilityStatus"
Copy link
Contributor

Choose a reason for hiding this comment

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

if the set of values has a chance of getting changed in the near future I'd suggest using "modelAsString": true here. (just be aware that otherwise, every change is a breaking change!)

Copy link
Contributor

Choose a reason for hiding this comment

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

also, please extract the data type you implicitly define here:

type: string
enum: ...
x-ms-enum: ...

into a top-level definition (with some generic description of what the enum represents) and just $reference it here and in all other places (valuable deduplication, especially in case of a change to the enum!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of these are likely to change. I'm happy to put the modelAsString back in if you think we still should.

@jaredmoo are you okay with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

They should not be modelasstring.

Copy link
Contributor

Choose a reason for hiding this comment

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

could you please still deduplicate the Swagger? There are 5 identical copies of this enum in here!

},
"description": "Represents the capabilities for a region."
},
"Resource": {
Copy link
Contributor

Choose a reason for hiding this comment

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

never referenced - note that you can also cross reference to other swagger files, so even if you plan to use a Resource in here, you can use the one defined in sql.core.json! Deduplication makes both reviewers and maintainers happy ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do I do this? When I did the initial checkin in October, I asked about this and was told it wasn't possible. I'd be happy to go through and remove all duplicates in another review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do I do this? When I did the initial checkin in October, I asked about this and was told it wasn't possible. I'd be happy to go through and remove all duplicates in another review.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh things have changed (to the better) since then :-) as per the Swagger standard, you can now give references such as ./sql.core.json#/definitions/Resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know! I'd like to keep this separate, since capabilities doesn't use Resource at all, but I will fix it in a future PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@olydis hey Johannes, I tried it out, and the linter is failing.

I moved SqlSubResource and Resource definitions to a Resource.json file, and change the reference to it like this:
"$ref": "./resource.json#/definitions/SqlSubResource"

Validate-spec continues to pass, but I get a linter error back: file: 'file:///e%3A/Azure/azure-rest-api-specs/arm-sql/2014-04-01/swagger/firewallRules.json'
severity: 'Error'
message: 'Error generating client model: Could not find file 'C'
at: '1,1'
source: 'lint'

I'm using linter 0.6.0. Am I doing the reference correctly?

Copy link
Contributor

Choose a reason for hiding this comment

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

what is "linter 0.6.0."? don't know that tool and sounds like it cannot handle external references

Copy link
Contributor Author

Choose a reason for hiding this comment

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

],
"x-ms-azure-resource": true
},
"SubResource": {
Copy link
Contributor

Choose a reason for hiding this comment

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

also not used

"name": {
"readOnly": true,
"type": "string",
"description": "The Service Objective name."
Copy link
Contributor

Choose a reason for hiding this comment

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

capitalization inconsistent, below you are talking about "server version" and "server edition" which reads well :-)

"DTU"
],
"x-ms-enum": {
"name": "PerformanceLevelUnit"
Copy link
Contributor

Choose a reason for hiding this comment

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

this again sounds like a good candidate for modelAsString: true or do you want adding a unit (seems likely from looking at it) to break everyone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also don't think this is likely to change either. I'm willing to add it, but Azure Team always wants to know why I'm adding modelAsString, and in this case I can't really say it's likely to change any time soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

@amarzavery can you take a quick look at this? aren't the ARM guidelines the opposite? Or what do you mean with "Azure Team" @nathannfan?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My experience in the past was that we're reluctant to use model-as-string:true unless it's actually likely to change. In this case, I don't think it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

this seems good to me. DTU is standard measuring unit and another one is not coming soon.

"description": "Represents the Service Objectives capabilities."
},
"PerformanceLevel": {
"description": "Represents a possible performance level of a Service Objective Capability.",
Copy link
Contributor

Choose a reason for hiding this comment

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

So the properties in here are not readonly? :-o

"Petabytes"
],
"x-ms-enum": {
"name": "MaxSizeUnits"
Copy link
Contributor

Choose a reason for hiding this comment

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

see other comments about enums

@olydis
Copy link
Contributor

olydis commented Mar 10, 2017

Apart from the above comments, this looks good to me, the CI issues have been addressed, I see you're discussing the validation messages regarding sql.core.json (where you've just improved descriptions) in #1005 👍

"Capabilities"
],
"operationId": "Capabilities_Get",
"description": "Returns information about the Azure SQL capabilities available for the specified region.",
Copy link
Contributor

Choose a reason for hiding this comment

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

also please replace 'region' with 'location' throughout this file, e.g.

"Gets the capabilities available for the specified location."

"limit": {
"readOnly": true,
"type": "integer",
"format": "int32",
Copy link
Contributor

Choose a reason for hiding this comment

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

will is always be int32? consider int64 here

"Capabilities"
],
"operationId": "Capabilities_Get",
"description": "Returns the capabilities available for the specified region.",
Copy link
Contributor

Choose a reason for hiding this comment

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

region -> location

"tags": [
"Capabilities"
],
"operationId": "Capabilities_Get",
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this technically Capabilities_List ? Since it returns a list. Or arguably Capabilities_ListByLocation

Copy link
Contributor

Choose a reason for hiding this comment

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

although, it does (technically) not just return a list, also name and status - otherwise our validation rules should also have caught it.

@nathannfan
Copy link
Contributor Author

nathannfan commented Mar 11, 2017

Hey @olydis, I'm not sure why the last two commits started failing validation. The error message doesn't say much, and my changes were mostly description updates.

Validate-spec, validate-example, linter and generate.cmd are all running without error as well. Is there a way to drill down deeper?

"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"name": "locationID",
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalization: locationId ?

],
"x-ms-enum": {
"name": "CapabilityStatus"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

description needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch, somehow our CI tools didn't catch that!

"edition": {
"type": "string",
"description": "The edition of the database. The DatabaseEditions enumeration contains all the valid editions. If createMode is NonReadableSecondary or OnlineSecondary, this value is ignored.",
"description": "The edition of the database. The DatabaseEditions enumeration contains all the valid editions. If createMode is NonReadableSecondary or OnlineSecondary, this value is ignored. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: \"Capabilities_Get.\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now Capabilities_List

Copy link
Contributor

@olydis olydis left a comment

Choose a reason for hiding this comment

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

LGTM (if @jaredmoo's comments are addressed)

@nathannfan
Copy link
Contributor Author

@olydis Hey Johannes, commits have been consistently failing build validation, and I'm not seeing much in the way of error messages in the build pages. Any tips on how to dig deeper?

Locally, it's still passing all validate-spec, validate-example, and successfully generating a client in SDK, which is odd.

Copy link
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.

LGTM

@olydis
Copy link
Contributor

olydis commented Mar 14, 2017

@nathannfan that's an internal issue that's hopefully gonna be resolved today

@cormacpayne
Copy link
Member

Swagger used to generate Azure/azure-sdk-for-net#2914

@olydis
Copy link
Contributor

olydis commented Mar 15, 2017

@nathannfan Tooling back up and running: You changing the description of the Resource model made it deviate from the other definitions of Resource (in other files referenced by compositeSql.json). AutoRest therefore rejects compositeSql.json right now! Please either change all other descriptions accordingly (so all definitions of Resource match up 100%) or just reference the Resource of another file instead of defining your own!

@jaredmoo
Copy link
Contributor

FYI I'm refactoring our references to Resource in #1005 . So Nathan will make minimal changes to Resource in this PR.

@nathannfan
Copy link
Contributor Author

@olydis I see what happened, the conflicting definition of Resource wasn't checked in when I sent the commit with the Resource description change. Should be good to go now.

"tags": [
"Capabilities"
],
"operationId": "Capabilities_List",
Copy link
Contributor

Choose a reason for hiding this comment

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

According to https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/swagger-good-patterns.md section "Consistency in the naming of list methods", this should be Capabilities_ListByLocation.

"unit": {
"type": "string",
"readOnly": true,
"description": "Unit type used to measure SLO performance level.",
Copy link
Contributor

Choose a reason for hiding this comment

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

"SLO" -> "service objective"

"Capabilities"
],
"operationId": "Capabilities_List",
"description": "Returns the capabilities available for the specified location.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid "Returns". How about "Gets"

"in": "path",
"required": true,
"type": "string",
"description": "The Id of the location for which the capabilities are retrieved."
Copy link
Contributor

Choose a reason for hiding this comment

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

The location id whose capabilities are retrieved

"definitions": {
"CapabilityStatus": {
"type": "string",
"description": "The availability status of the Capability",
Copy link
Contributor

Choose a reason for hiding this comment

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

Capability -> capability

"$ref": "#/definitions/CapabilityStatus"
}
},
"description": "Represents the maximum size limits for a database."
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "represents" here and in other descriptions. It's a useless word

"description": "Represents the service objectives capabilities."
},
"PerformanceLevel": {
"description": "Represents a possible performance level of a service objective Capability.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Capability -> capability

"status": {
"readOnly": true,
"type": "string",
"description": "The status for the location with respect to Azure SQL.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Azure SQL Database's status for the location.

@olydis olydis merged commit 7d9b6c0 into Azure:master Mar 17, 2017
@nathannfan
Copy link
Contributor Author

@olydis Thanks, Johannes!

@AutorestCI
Copy link

No modification for NodeJS

@AutorestCI
Copy link

@AutorestCI
Copy link

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.

7 participants