You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A tool that reflects the Docker client [engine-api](https://github.com/docker/engine-api) in order to generate C# classes that match its model for [Docker.DotNet Models](/src/Docker.DotNet/Models).
3
+
A tool that reflects the Docker client [engine-api](https://github.com/docker/engine-api) in order to generate C# classes that match its model for [Docker.DotNet Models](../../src/Docker.DotNet/Models).
4
4
5
5
----
6
6
@@ -14,25 +14,19 @@ To update the source repositories please use the following from your `$GOPATH`:
14
14
15
15
Note: Since the docker library is not a go module the version go generates will look something like this v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible even though this is for v19.03.13. The commit hash bd33bbf0497b matches the commit hash of docker v 19.03.13
16
16
17
-
Once you have the latest engine-api. Calling:
18
-
19
-
```
20
-
> update-generated-code.cmd
21
-
```
22
-
23
-
Should result in changes to the Docker.DotNet/Models directory if any exist.
17
+
Once you have the latest engine-api, call `update-generated-code.cmd` or `./update-generated-code.sh` (depending on your Operating System) to update the models in the [Docker.DotNet/Models](../../src/Docker.DotNet/Models) directory.
24
18
25
19
----
26
20
27
21
## About the structure of the tool:
28
22
29
23
Many of Docker's engine-api types are used for both the query string and json body. Because there is no way to attribute this on the engine-api types themselves we have broken the tool into a few specific areas:
30
24
31
-
`Csharptype.go`: Contains the translation/serialization code for writing the C# classes.
25
+
`Csharptype.go`: Contains the translation/serialization code for writing the C# classes.
32
26
33
27
`Modeldefs.go` : Contains the parts of engine-api that are used as parameters or require custom serialization that needs to be explicitly handled differently.
34
28
35
-
`Specgen.go`: Contains the majority of the code that reflects the engine-api structs and converts them to the C# in-memory abstractions.
29
+
`Specgen.go` : Contains the majority of the code that reflects the engine-api structs and converts them to the C# in-memory abstractions.
36
30
37
31
----
38
32
@@ -41,63 +35,55 @@ Many of Docker's engine-api types are used for both the query string and json bo
41
35
The resulting C# type contains both the `QueryString` parameters as well as the `JSON` body models in one object. This simplifies the calling API quite dramatically. For example:
What you are seeing here is that in order to interact with the remote API the query string allows `optional``stream` and `stdin` boolean parameters. Because they are optional the generated code adds the `?` to signify the absence of the value versus passing a `false` as the value.
Here you are actually seeing that the field values are marshalled in the request body based on the `DataMember` attribute. The resulting `JSON` will not contain the field if its value is equal to its default value in C#.
71
+
Here you are actually seeing that the field values are marshalled in the request body based on the `JsonPropertyName` attribute. The resulting `JSON` will not contain the field if its value is equal to its default value in C#.
83
72
84
-
A few customizations are taken in order to simplify the API even more. Take for example [RestartPolicyKind.cs](https://github.com/ahmetalpbalkan/Docker.DotNet/blob/master/Docker.DotNet/Models/RestartPolicyKind.cs). You will see the generated model contains:
73
+
A few customizations are taken in order to simplify the API even more. Take for example [RestartPolicyKind.cs](../../src/Docker.DotNet/Models/RestartPolicyKind.cs). You will see the generated model contains:
The property `Name` actually uses the enum value instead of its integer value. In order to do this because Go does not have enum values if you look at `specgen.go` you will see a `typeCustomizations` map where this field has been explicitly overridden in how its generated. You can use this model to accomplish more of the same where you see fit.
89
+
The property `Name` actually uses the `EnumMember` value instead of its integer value. In order to do this because Go does not have enum values if you look at `specgen.go` you will see a `typeCustomizations` map where this field has been explicitly overridden in how its generated. You can use this model to accomplish more of the same where you see fit.
0 commit comments