Skip to content

Commit

Permalink
Omit read-only content from request payloads (#450)
Browse files Browse the repository at this point in the history
* Omit read-only content from request payloads

Add `azure:"ro"` to fields marked as read-only.
Update azcore to version that supports exclusion of RO values.
Enabled RO test.
Added missing go.sum files.

* remove go.sum files until CI is fixed
  • Loading branch information
jhendrixMSFT authored Jul 28, 2020
1 parent b0e2c59 commit f0edff7
Show file tree
Hide file tree
Showing 12 changed files with 611 additions and 604 deletions.
2 changes: 1 addition & 1 deletion src/generator/gomod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function generateGoModFile(session: Session<CodeModel>): Promise<st
text += 'go 1.13\n\n';
// here we specify the minimum version of armcore/azcore as required by the code generator
// TODO: come up with a way to get the latest minor/patch versions.
const azcore = 'github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.0';
const azcore = 'github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.2';
if (session.model.language.go!.openApiType === 'arm') {
text += 'require (\n';
text += '\tgithub.com/Azure/azure-sdk-for-go/sdk/armcore v0.1.0\n';
Expand Down
6 changes: 5 additions & 1 deletion src/generator/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ class StructDef {
}
}
}
let tag = ` \`${this.Language.marshallingFormat}:"${serialization}"\``;
let readOnly = '';
if (prop.readOnly) {
readOnly = ` azure:"ro"`;
}
let tag = ` \`${this.Language.marshallingFormat}:"${serialization}"${readOnly}\``;
// if this is a response type then omit the tag IFF the marshalling format is
// JSON, it's a header or is the RawResponse field. XML marshalling needs a tag.
// also omit the tag for additionalProperties
Expand Down
1 change: 0 additions & 1 deletion test/autorest/complexgroup/readonlyproperty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestReadonlypropertyGetValid(t *testing.T) {
}

func TestReadonlypropertyPutValid(t *testing.T) {
t.Skip("R/O NYI, test fails")
client := getReadonlypropertyOperations(t)
id, size := "1234", int32(2)
result, err := client.PutValid(context.Background(), complexgroup.ReadonlyObj{ID: &id, Size: &size})
Expand Down
10 changes: 5 additions & 5 deletions test/autorest/generated/additionalpropsgroup/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/autorest/generated/complexgroup/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/autorest/generated/errorsgroup/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions test/autorest/generated/lrogroup/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
armnetwork v0.0.0-00010101000000-000000000000
azblob v0.0.0-00010101000000-000000000000
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.2
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.0
)

Expand Down
4 changes: 4 additions & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ github.com/Azure/azure-sdk-for-go/sdk/armcore v0.1.0 h1:i4/txgB7gpzLa3YBBPnSSXnR
github.com/Azure/azure-sdk-for-go/sdk/armcore v0.1.0/go.mod h1:/cH2D+NpD2KRgnop4cU+S5P2On5mP6KWgpWq48+Bt/M=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.0 h1:VdhfbVpQ3dkhXYOx/Wj1+utikcZkZSZSmpqmXWwaNJY=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.0/go.mod h1:hL9TGc07RkJVzDIBxsYXC/r0M+YiRkvl4z1elXCD+8s=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.2 h1:33m1ysGtf5EF8NOhH3pvVk9MfwnCQ0aGbfJelhZv1nE=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.2/go.mod h1:fBbm1JLvufiabxBiiZWThNODf8+bARgZ81aP3CEx3sg=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.2.0 h1:cLpVMIkXC/umSP9DMz9I6FttDWJAsmvhpaB6MlkagGY=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.2.0/go.mod h1:Q+TCQnSr+clUU0JU+xrHZ3slYCxw17AOFdvWFpQXjAY=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.2.1 h1:xY9/wUJ8PcxmTEJ6z+0qKuj9rb3Aw9nhiL+ik5evR/g=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.2.1/go.mod h1:Q+TCQnSr+clUU0JU+xrHZ3slYCxw17AOFdvWFpQXjAY=
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.0 h1:5PmE4x8xzfL3onRdC5adQPrJSMDhYT2h5DwPB1uR9tA=
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.0/go.mod h1:UL/d4lvWAzSJUuX+19uKdN0ktyjoOyQhgY+HWNgtIYI=
2 changes: 1 addition & 1 deletion test/network/2020-03-01/armnetwork/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.13

require (
github.com/Azure/azure-sdk-for-go/sdk/armcore v0.1.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.9.2
)
Loading

0 comments on commit f0edff7

Please sign in to comment.