Skip to content

Commit

Permalink
Fix swagger issues. (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Feb 14, 2024
1 parent 67256ac commit a951d71
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 78 deletions.
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type EmptyBody struct{}

type Identifiable struct {
ID string `json:"id" description:"the unique ID of this entity" unique:"true" required:"true"`
ID string `json:"id" description:"the unique ID of this entity" required:"true"`
}

type Describable struct {
Expand Down
6 changes: 3 additions & 3 deletions cmd/metal-api/internal/service/v1/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
type IPBase struct {
ProjectID string `json:"projectid" description:"the project this ip address belongs to"`
NetworkID string `json:"networkid" description:"the network this ip allocate request address belongs to"`
Type metal.IPType `json:"type" default:"static" enum:"static|ephemeral" description:"the ip type, ephemeral leads to automatic cleanup of the ip address, static will enable re-use of the ip at a later point in time"`
Type metal.IPType `json:"type" enum:"static|ephemeral" description:"the ip type, ephemeral leads to automatic cleanup of the ip address, static will enable re-use of the ip at a later point in time"`
Tags []string `json:"tags" description:"free tags that you associate with this ip." optional:"true"`
}

type IPIdentifiable struct {
IPAddress string `json:"ipaddress" modelDescription:"an ip address that can be attached to a machine" description:"the address (ipv4 or ipv6) of this ip" unique:"true" readonly:"true"`
IPAddress string `json:"ipaddress" modelDescription:"an ip address that can be attached to a machine" description:"the address (ipv4 or ipv6) of this ip" readonly:"true"`
AllocationUUID string `json:"allocationuuid" description:"a unique identifier for this ip address allocation, can be used to distinguish between ip address allocation over time." readonly:"true"`
}

Expand All @@ -24,7 +24,7 @@ type IPAllocateRequest struct {
}

type IPUpdateRequest struct {
IPAddress string `json:"ipaddress" modelDescription:"an ip address that can be attached to a machine" description:"the address (ipv4 or ipv6) of this ip" unique:"true" readonly:"true"`
IPAddress string `json:"ipaddress" modelDescription:"an ip address that can be attached to a machine" description:"the address (ipv4 or ipv6) of this ip" readonly:"true"`
Describable
Type metal.IPType `json:"type" enum:"static|ephemeral" description:"the ip type, ephemeral leads to automatic cleanup of the ip address, static will enable re-use of the ip at a later point in time"`
Tags []string `json:"tags" description:"free tags that you associate with this ip." optional:"true"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type NetworkUsage struct {

// NetworkCreateRequest is used to create a new Network.
type NetworkCreateRequest struct {
ID *string `json:"id" description:"the unique ID of this entity, auto-generated if left empty" unique:"true"`
ID *string `json:"id" description:"the unique ID of this entity, auto-generated if left empty"`
Describable
NetworkBase
NetworkImmutable
Expand Down
9 changes: 8 additions & 1 deletion cmd/metal-api/internal/service/v1/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ func NewPartitionResponse(p *metal.Partition) *PartitionResponse {
if p == nil {
return nil
}

prefixLength := int(p.PrivateNetworkPrefixLength)

labels := map[string]string{}
if p.Labels != nil {
labels = p.Labels
}

return &PartitionResponse{
Common: Common{
Identifiable: Identifiable{
Expand All @@ -90,7 +97,7 @@ func NewPartitionResponse(p *metal.Partition) *PartitionResponse {
Created: p.Created,
Changed: p.Changed,
},
Labels: p.Labels,
Labels: labels,
}
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/metal-api/internal/service/v1/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func NewSizeResponse(s *metal.Size) *SizeResponse {
reservations = append(reservations, reservation)
}

labels := map[string]string{}
if s.Labels != nil {
labels = s.Labels
}

return &SizeResponse{
Common: Common{
Identifiable: Identifiable{
Expand All @@ -131,6 +136,6 @@ func NewSizeResponse(s *metal.Size) *SizeResponse {
Created: s.Created,
Changed: s.Changed,
},
Labels: s.Labels,
Labels: labels,
}
}
Loading

0 comments on commit a951d71

Please sign in to comment.