Skip to content

Commit

Permalink
introduce openapi defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Mortari <[email protected]>
  • Loading branch information
tarilabs committed Feb 22, 2024
1 parent 2edb456 commit d94f7f4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions api/openapi/model-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ components:
metadataType:
type: string
example: MetadataIntValue
default: MetadataIntValue
MetadataDoubleValue:
description: A double property value.
type: object
Expand All @@ -1138,6 +1139,7 @@ components:
metadataType:
type: string
example: MetadataDoubleValue
default: MetadataDoubleValue
MetadataStringValue:
description: A string property value.
type: object
Expand All @@ -1150,6 +1152,7 @@ components:
metadataType:
type: string
example: MetadataStringValue
default: MetadataStringValue
MetadataStructValue:
description: A struct property value.
type: object
Expand All @@ -1163,6 +1166,7 @@ components:
metadataType:
type: string
example: MetadataStructValue
default: MetadataStructValue
MetadataProtoValue:
description: A proto property value.
type: object
Expand All @@ -1180,6 +1184,7 @@ components:
metadataType:
type: string
example: MetadataProtoValue
default: MetadataProtoValue
MetadataBoolValue:
description: A bool property value.
type: object
Expand All @@ -1192,6 +1197,7 @@ components:
metadataType:
type: string
example: MetadataBoolValue
default: MetadataBoolValue
BaseResource:
allOf:
- $ref: "#/components/schemas/BaseResourceCreate"
Expand Down
20 changes: 15 additions & 5 deletions internal/converter/mlmd_openapi_converter_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ import (
)

func NewMetadataStringValue(value string) *openapi.MetadataStringValue {
return openapi.NewMetadataStringValue(value, "MetadataStringValue")
result := openapi.NewMetadataStringValueWithDefaults()
result.StringValue = value
return result
}

func NewMetadataBoolValue(value bool) *openapi.MetadataBoolValue {
return openapi.NewMetadataBoolValue(value, "MetadataBoolValue")
result := openapi.NewMetadataBoolValueWithDefaults()
result.BoolValue = value
return result
}

func NewMetadataDoubleValue(value float64) *openapi.MetadataDoubleValue {
return openapi.NewMetadataDoubleValue(value, "MetadataDoubleValue")
result := openapi.NewMetadataDoubleValueWithDefaults()
result.DoubleValue = value
return result
}

func NewMetadataIntValue(value string) *openapi.MetadataIntValue {
return openapi.NewMetadataIntValue(value, "MetadataIntValue")
result := openapi.NewMetadataIntValueWithDefaults()
result.IntValue = value
return result
}

func NewMetadataStructValue(value string) *openapi.MetadataStructValue {
return openapi.NewMetadataStructValue(value, "MetadataStructValue")
result := openapi.NewMetadataStructValueWithDefaults()
result.StructValue = value
return result
}

// MapMLMDCustomProperties maps MLMD custom properties model to OpenAPI one
Expand Down
2 changes: 2 additions & 0 deletions pkg/openapi/model_metadata_bool_value.go

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

2 changes: 2 additions & 0 deletions pkg/openapi/model_metadata_double_value.go

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

2 changes: 2 additions & 0 deletions pkg/openapi/model_metadata_proto_value.go

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

2 changes: 2 additions & 0 deletions pkg/openapi/model_metadata_string_value.go

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

2 changes: 2 additions & 0 deletions pkg/openapi/model_metadata_struct_value.go

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

0 comments on commit d94f7f4

Please sign in to comment.