-
Notifications
You must be signed in to change notification settings - Fork 43
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
Implement discriminator support in v3 generator #113
Conversation
Here is sample genereated from Files swagger : Swagger is there also: |
/// <summary> | ||
/// Gets if the property should be treated as a pointer | ||
/// </summary> | ||
public bool IsPointer => !(this.ModelType.HasInterface() || IsRequired || ModelType.CanBeNull() || ModelType is EnumTypeGo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EnumTypeGo [](start = 120, length = 10)
in v2 we had the extra condition here to be a named enum to be a value type. But I saw we were not using that in v3. Let me know if we want to add the extra criteria
@@ -17,7 +17,6 @@ public class CodeGeneratorGo : CodeGenerator | |||
private const string ModelsFileName = "models"; | |||
private const string ClientFileName = "client"; | |||
private const string VersionFileName = "version"; | |||
private const string MarshallingFileName = "marshalling"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MarshallingFileName [](start = 29, length = 19)
note that I removed the marshalling file from the output. it seems most of it should go to the models file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this file was to separate the exported types from the non-exported types/implementation details (i.e. the content of marshalling.go is interesting to us but not to consumers of the SDK). If merging this into the models file makes it easier to generate the content then we can leave it merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, but I think to keep the generator code cleaner its easier to put them in the models also would prefer to have all the publicly used types ( and their marshallers ) to be in the models.
src/Templates/ModelTemplate.cshtml
Outdated
return d.DecodeElement(@local, &start) | ||
} | ||
</text> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go in the marshallingxml template
@using AutoRest.Core.Model | ||
@using AutoRest.Core.Utilities | ||
@using AutoRest.Go | ||
@using AutoRest.Go.Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main interest is on the xml so maybe focus on this one
Also note that right now for XML we are using the tag names to determine the specific type in polymorphic situations. This is what storage supports right now. |
case PrimaryTypeGo primaryType: | ||
primaryType.AddImports(imports); | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default [](start = 16, length = 7)
Could a different go type arrive here? Something different to a sequence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have it the same in the v2 generator. looking at it, Composite Type also has AddImports but that will be just the imports of its fields
@EmptyLine | ||
@if (values.Any()) | ||
@if (Model.Values.Any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the above declaration of values no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ill remove
🤖 AutoRest automatic publish job 🤖success (version: 3.0.46) |
7191b0e
to
531d631
Compare
for blobs look at changes introduced in the last commit : https://github.com/vladbarosan/azure-storage-blob-go/tree/vladdb |
531d631
to
7718176
Compare
src/Model/CodeModelGo.cs
Outdated
return $"Azure-SDK-For-Go/{Version} arm-{Namespace}/{ApiVersion}"; | ||
} | ||
} | ||
public string UserAgent => $"Azure-SDK-For-Go/{Version} arm-{Namespace}/{ApiVersion}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small tweak unrelated, could you remove that "arm-" prefix?
@@ -70,18 +70,18 @@ type Error struct { | |||
} | |||
|
|||
// Response returns the raw HTTP response object. | |||
func (e Error) Response() *http.Response { | |||
return e.rawResponse | |||
func (eVar Error) Response() *http.Response { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this var name changed? Not a big deal, just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we added a couple of reserved names and e
was one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with just a few comments/questions.
0b1e161
to
8e78dd1
Compare
Fixes Azure/azure-sdk-for-go#1177