Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve redis Swagger. #2969

Merged
merged 2 commits into from
May 3, 2018
Merged

Conversation

TimLovellSmith
Copy link
Member

@TimLovellSmith TimLovellSmith commented Apr 27, 2018

Documenting list all patchSchedules to fix #2968. Documenting the CheckNameAvailability.type property better to fix #2967. And using a realistic timespan value in PatchSchedule examples.

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

/cc @SiddharthChatrolaMs

@AutorestCI
Copy link

AutorestCI commented Apr 27, 2018

Automation for azure-sdk-for-python

The initial PR has been merged into your service PR:
Azure/azure-sdk-for-python#2091

@AutorestCI
Copy link

AutorestCI commented Apr 27, 2018

Automation for azure-libraries-for-java

The initial PR has been merged into your service PR:
AutorestCI/azure-libraries-for-java#122

@AutorestCI
Copy link

AutorestCI commented Apr 27, 2018

Automation for azure-sdk-for-node

Encountered a Subprocess error: (azure-sdk-for-node)

Command: ['/usr/local/bin/autorest', '/tmp/tmpnwblaga6/rest/specification/redis/resource-manager/readme.md', '--license-header=MICROSOFT_MIT_NO_VERSION', '--node-sdks-folder=/tmp/tmpnwblaga6/sdk', '--nodejs', '--use=@microsoft.azure/autorest.nodejs@^2.1.43']
Finished with return code 1
and output:

AutoRest code generation utility [version: 2.0.4262; node: v7.10.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      '/root/.autorest/@microsoft.azure_autorest-core@2.0.4272/node_modules/@microsoft.azure/autorest-core/dist' (2.0.4272)
   Loading AutoRest extension '@microsoft.azure/autorest.nodejs' (^2.1.43->2.1.46)
   Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.44->2.3.44)
FATAL: System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
   at AutoRest.Extensions.SwaggerExtensions.RemoveUnreferencedTypes(CodeModel codeModel, HashSet`1 typeNames)
   at AutoRest.Extensions.SwaggerExtensions.FlattenModels(CodeModel codeModel)
   at AutoRest.Extensions.Azure.AzureExtensions.NormalizeAzureClientModel(CodeModel codeModel)
   at AutoRest.NodeJS.Azure.TransformerJsa.AutoRest.Core.ITransformer<AutoRest.NodeJS.Azure.Model.CodeModelJsa>.TransformCodeModel(CodeModel cm) in Z:\PUBLISHwybeg\46_20180403T154736\autorest.nodejs\src\azure\TransformerJsa.cs:line 34
   at AutoRest.NodeJS.Program.<ProcessInternal>d__3.MoveNext() in Z:\PUBLISHwybeg\46_20180403T154736\autorest.nodejs\src\Program.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NewPlugin.<Process>d__15.MoveNext()
FATAL: nodejs/generate - FAILED
FATAL: Error: Plugin nodejs reported failure.
Process() cancelled due to exception : Plugin nodejs reported failure.
  Error: Plugin nodejs reported failure.

@AutorestCI
Copy link

AutorestCI commented Apr 27, 2018

Automation for azure-sdk-for-go

A PR has been created for you based on this PR content.

Once this PR will be merged, content will be added to your service PR:
Azure/azure-sdk-for-go#1778

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@TimLovellSmith
Copy link
Member Author

Autorest node generator appears to be crashing:

INFO:swaggertosdk.autorest_tools:   Loading AutoRest core      '/root/.autorest/@microsoft.azure_autorest-core@2.0.4275/node_modules/@microsoft.azure/autorest-core/dist' (2.0.4275)

INFO:swaggertosdk.autorest_tools:   Installing AutoRest extension '@microsoft.azure/autorest.nodejs' (^2.1.43)

INFO:swaggertosdk.autorest_tools:   Installing AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.44)

INFO:swaggertosdk.autorest_tools:FATAL: System.InvalidOperationException: Sequence contains no matching element

INFO:swaggertosdk.autorest_tools:   at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)

INFO:swaggertosdk.autorest_tools:   at AutoRest.Extensions.SwaggerExtensions.RemoveUnreferencedTypes(CodeModel codeModel, HashSet`1 typeNames)

INFO:swaggertosdk.autorest_tools:   at AutoRest.Extensions.SwaggerExtensions.FlattenModels(CodeModel codeModel)

INFO:swaggertosdk.autorest_tools:   at AutoRest.Extensions.Azure.AzureExtensions.NormalizeAzureClientModel(CodeModel codeModel)

INFO:swaggertosdk.autorest_tools:   at AutoRest.NodeJS.Azure.TransformerJsa.AutoRest.Core.ITransformer<AutoRest.NodeJS.Azure.Model.CodeModelJsa>.TransformCodeModel(CodeModel cm) in /opt/vsts/work/1/s/src/azure/TransformerJsa.cs:line 34

INFO:swaggertosdk.autorest_tools:   at AutoRest.NodeJS.Program.<ProcessInternal>d__3.MoveNext() in /opt/vsts/work/1/s/src/Program.cs:line 125

INFO:swaggertosdk.autorest_tools:--- End of stack trace from previous location where exception was thrown ---

INFO:swaggertosdk.autorest_tools:   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

INFO:swaggertosdk.autorest_tools:   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

INFO:swaggertosdk.autorest_tools:   at NewPlugin.<Process>d__15.MoveNext()

INFO:swaggertosdk.autorest_tools:FATAL: nodejs/generate - FAILED

INFO:swaggertosdk.autorest_tools:FATAL: Error: Plugin nodejs reported failure.

INFO:swaggertosdk.autorest_tools:Process() cancelled due to exception : Plugin nodejs reported failure.

INFO:swaggertosdk.autorest_tools:  Error: Plugin nodejs reported failure.

"properties": {
"name": {
"type": "string",
"description": "Resource name."
},
"type": {
"type": "string",
"description": "Resource type."
"description": "Resource type to check name availability of, e.g. 'Microsoft.Cache/redis'.",
"enum": [
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to keep this as string? Changing the type from string to enum (even with modelAsString) will be a breaking change in many languages.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jhendrixMSFT What say you?

Copy link
Member

Choose a reason for hiding this comment

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

I'm torn on this as breaking changes stink however in this case there was no clue what to pass for the value (I had to look at the checked in example JSON to figure it out). If we really don't want to take the breaking change then the doc string will have to be the source of truth.
Another thing to consider, if this param will only ever have the value "Microsoft.Cache/redis" then if you mark it "modelAsString": false AutoRest should treat it as a constant and remove the param entirely (i.e. hard-coding the value in the request).

Copy link
Member Author

Choose a reason for hiding this comment

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

@jhendrixMSFT
For this api-version we don't have any other resource types, and if we ever have a new resource we can use a new api-version for it. So I think it's fine to treat it as a constant.
Let's try that out and see if that makes everyone happy!
/cc @jianghaolu

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@TimLovellSmith
Copy link
Member Author

I see linter validation errors..
I think it is just because the parameter got removed and I need to remove it from the example too.
Trying that now..

`
error: Found errors in validating the request for x-ms-example "RedisCacheList" in operation "Redis_CheckNameAvailability".:

{ code: 'REQUEST_VALIDATION_ERROR',

id: 'OAV109',

message: 'Found errors in validating the request for x-ms-example "RedisCacheList" in operation "Redis_CheckNameAvailability".',

innerErrors:

[ { code: 'INVALID_REQUEST_PARAMETER',

   errors: 

    [ { code: 'ONE_OF_MISSING',

        params: [],

        message: 'Data does not match any schemas from \'oneOf\'',

        path: [ 'type' ],

        inner: 

         [ { code: 'ENUM_MISMATCH',

             params: [ 'Microsoft.Cache/Redis' ],

             message: 'No enum match for: Microsoft.Cache/Redis',

             path: [ 'type' ],

             description: 'Resource type to check name availability of, e.g. \'Microsoft.Cache/redis\'.' },

           { code: 'INVALID_TYPE',

             params: [ 'null', 'string' ],

             message: 'Expected type null but found type string',

             path: [ 'type' ] } ] } ],

   in: 'body',

   message: 'Invalid parameter (parameters): Value failed JSON Schema validation',

   name: 'parameters',

   path: 

    [ 'paths',

      '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/CheckNameAvailability',

      'post',

      'parameters',

      '0' ] } ] }

{ AssertionError [ERR_ASSERTION]: swagger "specification/redis/resource-manager/Microsoft.Cache/stable/2018-03-01/redis.json" contains model validation errors.

at Context.<anonymous> (/home/travis/build/Azure/azure-rest-api-specs/test/model.js:20:16)

at <anonymous>

generatedMessage: false,

name: 'AssertionError [ERR_ASSERTION]',

code: 'ERR_ASSERTION',

actual: false,

expected: true,

operator: '==' }

1 passing (3s)

1 failing

  1. Azure swagger model validation using x-ms-examples and examples in spec

    specification/redis/resource-manager/Microsoft.Cache/stable/2018-03-01/redis.json should have valid examples.:

    AssertionError [ERR_ASSERTION]: swagger "specification/redis/resource-manager/Microsoft.Cache/stable/2018-03-01/redis.json" contains model validation errors.

    • expected - actual

    -false

    +true

    at Context. (test/model.js:20:16)

    at
    `

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@TimLovellSmith
Copy link
Member Author

@jhendrixMSFT @jianghaolu
Looks like removing the parameter and adding the enum type still gets flagged as a breaking change by AutoRest. Do you think that this is really a good idea?

If it were possible, I would rather do this in a non-breaking way (i.e. keep it string) but with a 'default' parameter value supplied, so that anyone writing new code wouldn't have to feel confused about what type to supply. Do you know if that is possible?

@jhendrixMSFT
Copy link
Member

The question of default value has come up before and I don't believe there is support for this. So if we want to do it in a non-breaking way the only real option that I know of is to update the comment like you already did.
CC @fearthecowboy

@TimLovellSmith
Copy link
Member Author

@jhendrixMSFT Given that we have other issues with CheckNameAvailability, which might be another breaking change, and a new api-version to fix (I refer to #2981) I think the best thing to do is NOT do any breaking change to the generated code for this api-version, but just document it for this api version and CONSIDER modeling it as an enum next api-version, and then people will hopefully notice the return type is changing at the same time as they are fixing up build issues for the number of arguments change.

So, for this PR, I am just going to improve the documentation, and revert the model as enum changes. I hope this makes sense.

/cc @fearthecowboy @hovsepm @jianghaolu

…zure#2968. Documenting the 'CheckNameAvailability.type' property better to address Azure#2967 (and marking properties as required). Also using a more realistic timespan value in the PatchSchedule examples.
@azuresdkciprbot
Copy link

AutoRest linter results for SDK Related Validation Errors/Warnings

These errors are reported by the SDK team's validation tools, reachout to ADX Swagger Reviewers directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@azuresdkciprbot
Copy link

AutoRest linter results for ARM Related Validation Errors/Warnings

These errors are reported by the ARM team's validation tools, reachout to ARM RP API Review directly for any questions or concerns.

File: specification/redis/resource-manager/readme.md

⚠️0 new Warnings.(0 total)
0 new Errors.(0 total)

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@TimLovellSmith
Copy link
Member Author

@jhendrixMSFT @jianghaolu Is this PR good enough now?

@TimLovellSmith
Copy link
Member Author

@jhendrixMSFT @jianghaolu Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants