Skip to content
Open
59 changes: 55 additions & 4 deletions platform-api/api/generated.go

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

39 changes: 29 additions & 10 deletions platform-api/internal/dto/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ type Vhosts struct {

// APIYAMLData represents a basic spec section of the API deployment YAML
type APIYAMLData struct {
DisplayName string `yaml:"displayName"`
Version string `yaml:"version"`
Context string `yaml:"context"`
SubscriptionPlans []string `yaml:"subscriptionPlans,omitempty"`
Vhosts *Vhosts `yaml:"vhosts,omitempty"`
Upstream *UpstreamYAML `yaml:"upstream,omitempty"`
Policies []Policy `yaml:"policies,omitempty"`
Operations []api.OperationRequest `yaml:"operations,omitempty"`
Channels []api.ChannelRequest `yaml:"channels,omitempty"`
DisplayName string `yaml:"displayName"`
Version string `yaml:"version"`
Context string `yaml:"context"`
SubscriptionPlans []string `yaml:"subscriptionPlans,omitempty"`
Vhosts *Vhosts `yaml:"vhosts,omitempty"`
Upstream *UpstreamYAML `yaml:"upstream,omitempty"`
UpstreamDefinitions []ReusableUpstreamYAML `yaml:"upstreamDefinitions,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we rename this ReusableUpstreamYAML to something more aligning like []UpstreamDefinition? Any limitation in doing a rename like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UpstreamDefinition is already a pre-existing platform-api schema/type, used for the API-level upstream.main/sandbox endpoint (the url | ref | auth union). It predates this PR:

UpstreamDefinition:
type: object
oneOf:
- required: [ "url" ]
- required: [ "ref" ]
description: Upstream endpoint configuration (single target or reference)
properties:
url:
type: string
format: uri
description: Direct backend URL to route traffic to
example: http://prod-backend:5000/api/v2
ref:
type: string
description: Reference to a predefined upstreamDefinition
auth:
$ref: '#/components/schemas/UpstreamAuth'

That is why the new pool entry is ReusableUpstream: renaming it to UpstreamDefinition would collide with that existing type in both the OpenAPI components and the generated Go.

For context, the gateway's management-openapi.yaml uses the opposite terminology, Upstream for the endpoint and UpstreamDefinition for the pool entry, so the two planes already name these concepts differently, independent of this PR.

Policies []Policy `yaml:"policies,omitempty"`
Operations []api.OperationRequest `yaml:"operations,omitempty"`
Channels []api.ChannelRequest `yaml:"channels,omitempty"`
}

// UpstreamYAML represents the upstream configuration for API deployment YAML
Expand All @@ -160,10 +161,28 @@ type UpstreamTarget struct {
Ref string `yaml:"ref,omitempty"`
}

// ReusableUpstreamYAML represents a named entry in the deployment YAML's upstreamDefinitions pool.
type ReusableUpstreamYAML struct {
Name string `yaml:"name"`
BasePath string `yaml:"basePath,omitempty"`
Timeout *UpstreamTimeoutYAML `yaml:"timeout,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the YAML part in this type? Can we maybe use just UpstreamTimeout?

Upstreams []UpstreamBackendYAML `yaml:"upstreams"`
}

// UpstreamBackendYAML represents a weighted backend target within a reusable upstream.
type UpstreamBackendYAML struct {
URL string `yaml:"url"`
Weight *int `yaml:"weight,omitempty"`
}

// UpstreamTimeoutYAML represents the timeout configuration for a reusable upstream.
type UpstreamTimeoutYAML struct {
Connect string `yaml:"connect,omitempty"`
}

// APIListResponse represents a paginated list of APIs (constitution-compliant)
type APIListResponse struct {
Count int `json:"count" yaml:"count"` // Number of items in current response
List []*API `json:"list" yaml:"list"` // Array of API objects
Pagination Pagination `json:"pagination" yaml:"pagination"` // Pagination metadata
}

Loading
Loading