-
Notifications
You must be signed in to change notification settings - Fork 6k
Open
Description
Description
As per title, I am trying to generate the model classes for the docker api swagger spec, this contains a number of nullable properties of format "integer" and format "int64". They are being generated as long?
but then given a default value which indicates it is a float, e.g. long? size = -1F
which causes a compiler error.
Swagger-codegen version
3.0.65
Swagger declaration file content or url
UsageData:
type: "object"
x-nullable: true
x-go-name: "UsageData"
required: [Size]
description: |
Usage details about the volume. This information is used by the
`GET /system/df` endpoint, and omitted in other endpoints.
properties:
Size:
type: "integer"
format: "int64"
default: -1
description: |
Amount of disk space used by the volume (in bytes). This information
is only available for volumes created with the `"local"` volume
driver. For volumes created with other volume drivers, this field
is set to `-1` ("not available")
x-nullable: false
produces
/// <summary>
/// Initializes a new instance of the <see cref="VolumeUsageData" /> class.
/// </summary>
/// <param name="size">Amount of disk space used by the volume (in bytes). This information is only available for volumes created with the `\"local\"` volume driver. For volumes created with other volume drivers, this field is set to `-1` (\"not available\") (required) (default to -1F).</param>
public VolumeUsageData(long? size = -1F)
Command line used for generation
docker run --rm --network=host -v ${PWD}:/local swaggerapi/swagger-codegen-cli-v3 generate \
-i http://localhost:3000/swagger.yaml \
-l csharp \
-Dmodels \
--additional-properties=resolveMethodConflicts=true \
-c /local/config.json \
-o /local/out/csharp
Steps to reproduce
-
Using the following docker swagger spec (which originally came from here)
swagger.yaml.zip -
Host the swagger-ui mounting this spec file in
docker run -p 3000:8080 -e SWAGGER_JSON=/swagger.yaml -v $(pwd)/swagger.yaml:/swagger.yaml swaggerapi/swagger-ui
- Generate the C# code with the following
docker run --rm --network=host -v ${PWD}:/local swaggerapi/swagger-codegen-cli-v3 generate \
-i http://localhost:3000/swagger.yaml \
-l csharp \
-Dmodels \
--additional-properties=resolveMethodConflicts=true \
-c /local/config.json \
-o /local/out/csharp
- Observe all the default float values being given for longs when you try to build it.
Related issues/PRs
None found
Suggest a fix/enhancement
Feels like somewhere along the way nullable int64 types are being treated as floats somewhere between the correct mapping into an actual C# type (a long?
) and working out what default value to use.
Metadata
Metadata
Assignees
Labels
No labels