Skip to content

Commit

Permalink
doc: Fix type descriptions in generated REST API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
alanconway committed Sep 9, 2024
1 parent 0788ab4 commit 63d713a
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ help: ## Display this help.
@grep -E '^## [A-Z0-9_]+: ' Makefile | sed 's/^## \([A-Z0-9_]*\): \(.*\)/\1#\2/' | column -s'#' -t

## VERSION: Semantic version for release, use -dev for development pre-release versions.
VERSION?=0.7.2
VERSION?=0.7.3-dev
## REGISTRY: Name of image registry
REGISTRY?=quay.io
## REGISTRY_ORG: Name of registry organization.
Expand Down
1 change: 1 addition & 0 deletions doc/README.adoc
93 changes: 80 additions & 13 deletions doc/gen/rest_api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ GET /api/v1alpha1/domains/{domain}/classes
| `string`
|
| required
|
|
| Domain name

|===
Expand Down Expand Up @@ -167,7 +167,7 @@ GET /api/v1alpha1/objects
| `string`
|
| required
|
|
| query string

|===
Expand Down Expand Up @@ -228,7 +228,7 @@ POST /api/v1alpha1/graphs/goals
| `bool`
|
| optional
|
|
| include rules in graph edges

| request | `body` | link:#goals[Goals] | `models.Goals` | | ✓ | | search from start to goal classes
Expand Down Expand Up @@ -291,7 +291,7 @@ POST /api/v1alpha1/graphs/neighbours
| `bool`
|
| optional
|
|
| include rules in graph edges

| request | `body` | link:#neighbours[Neighbours] | `models.Neighbours` | | ✓ | | search from neighbours
Expand Down Expand Up @@ -395,18 +395,45 @@ any
=== Classes


> Classes is a map from class names to a short description.
Classes is a map from class names to a short description.




link:#classes[Classes]

[id=constraint]
=== Constraint


Constraint constrains the objects that will be included in search results.






**Properties**

[%autowidth]
|===
| Name | Type | Go type | Required | Default | Description | Example

| end | date-time (formatted string)| `strfmt.DateTime` | | | End of time interval, quoted RFC 3339 format. |

| limit | integer| `int64` | | | Limit number of objects returned per query, <=0 means no limit. |

| start | date-time (formatted string)| `strfmt.DateTime` | | | Start of time interval, quoted RFC 3339 format. |

| timeout | string| `string` | | | Timeout per request, h/m/s/ms/ns format |

|===

[id=domain]
=== Domain


> Domain configuration information.
Domain configuration information.



Expand All @@ -429,7 +456,7 @@ link:#classes[Classes]
=== Edge


> Directed edge in the result graph, from Start to Goal classes.
Directed edge in the result graph, from Start to Goal classes.



Expand All @@ -454,15 +481,30 @@ link:#classes[Classes]
=== Goals


Starting point for a goals search.


link:#interface[interface{}]




**Properties**

[%autowidth]
|===
| Name | Type | Go type | Required | Default | Description | Example

| goals | []string| `[]string` | | | Goal classes for correlation. | `["domain:class"]`

| start | link:#start[Start]| `Start` | | | |

|===

[id=graph]
=== Graph


> Graph resulting from a correlation search.
Graph resulting from a correlation search.



Expand All @@ -485,7 +527,7 @@ link:#interface[interface{}]
=== Neighbours


> Starting point for a neighbours search.
Starting point for a neighbours search.



Expand All @@ -508,10 +550,13 @@ link:#interface[interface{}]
=== Node


Node in the result graph, contains results for a single class.






**Properties**

[%autowidth]
Expand All @@ -530,7 +575,7 @@ link:#interface[interface{}]
=== QueryCount


> Query run during a correlation with a count of results found.
Query run during a correlation with a count of results found.



Expand All @@ -553,10 +598,13 @@ link:#interface[interface{}]
=== Rule


Rule is a correlation rule with a list of queries and results counts found during navigation.






**Properties**

[%autowidth]
Expand All @@ -573,15 +621,34 @@ link:#interface[interface{}]
=== Start


Start identifies a set of starting objects for correlation.


link:#interface[interface{}]




**Properties**

[%autowidth]
|===
| Name | Type | Go type | Required | Default | Description | Example

| class | string| `string` | | | Class for `objects` |

| constraint | link:#constraint[Constraint]| `Constraint` | | | |

| objects | link:#interface[interface{}]| `interface{}` | | | Objects of `class` serialized as JSON |

| queries | []string| `[]string` | | | Queries for starting objects |

|===

[id=store]
=== Store


> Store is a map of name:value attributes used to connect to a store.
Store is a map of name:value attributes used to connect to a store.



Expand Down
26 changes: 13 additions & 13 deletions etc/swagger/markdown/docs.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ https://github.com/go-swagger/go-swagger/blob/master/generator/templates/markdow
{{- with .ExternalDocs }}
{{- if .URL }}
{{- if .Description }}
> {{ .URL }}[{{ trimSpace .Description }}]
{{ .URL }}[{{ trimSpace .Description }}]
{{- else }}
> {{ .URL }}[Read more]
{{ .URL }}[Read more]
{{- end }}
{{- else }}
> {{ trimSpace .Description }}
{{ trimSpace .Description }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -25,7 +25,7 @@ https://github.com/go-swagger/go-swagger/blob/master/generator/templates/markdow
| `{{ .GoType }}`
| {{ if .CollectionFormat }}`{{ docCollectionFormat .CollectionFormat .Child }}`{{ end }}
| {{ if .Required }}required{{else}}optional{{ end }}
| {{ if .Default }}`{{ json .Default }}`{{ end }}
| {{ if .Default }}`{{ json .Default }}`{{ end }}
| {{ trimSpace .Description }}

{{- end }}
Expand Down Expand Up @@ -148,7 +148,7 @@ any

{{- define "docModel" }}{{/* renders a definition */}}
{{- with .Description }}
> {{ .}}
{{ .}}
{{- end }}
{{- if .ExternalDocs }}
{{ template "externalDoc" . }}
Expand Down Expand Up @@ -297,20 +297,20 @@ Produces::

{{- with .Type }}

> **Type**: {{ . }}
**Type**: {{ . }}
{{- end }}
{{- if .IsOAuth2}}
{{- with .Flow }}
>
> **Flow**: {{ . }}

**Flow**: {{ . }}
{{- end }}
{{- with .AuthorizationURL }}
>
> **Authorization URL**: {{ . }}

**Authorization URL**: {{ . }}
{{- end }}
{{- with .TokenURL }}
>
> **Token URL**: {{ . }}

**Token URL**: {{ . }}
{{- end }}
{{ if .ScopesDesc }}

Expand Down Expand Up @@ -384,7 +384,7 @@ Produces::

{{- with .ExternalDocs }}

> {{ if .URL }}[Read more]({{ .URL }} "{{ .Description }}"){{ end }}
{{ if .URL }}[Read more]({{ .URL }} "{{ .Description }}"){{ end }}
{{- end }}

{{- if or (gt (len .SchemeOverrides) 0) (gt (len .ExtraSchemeOverrides) 0) }}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/build/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.7.3-dev
10 changes: 5 additions & 5 deletions pkg/korrel8r/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/korrel8r/korrel8r/pkg/ptr"
)

// Constraint included in a reference to restrict the resulting objects.
// Constraint included in a store Get operation to restrict the resulting objects.
type Constraint struct {
Limit *int `json:"limit,omitempty"` // Limit number of objects returned per query, <=0 means no limit.
Timeout *time.Duration `json:"timeout,omitempty"` // Timeout per request.
Start *time.Time `json:"start,omitempty"` // Start of time interval to include.
End *time.Time `json:"end,omitempty"` // End of time interval to include.
Limit *int `json:"limit,omitempty"` // Limit number of objects returned per query, <=0 means no limit.
Timeout *time.Duration `json:"timeout,omitempty" swaggertype:"string"` // Timeout per request, h/m/s/ms/ns format
Start *time.Time `json:"start,omitempty" swaggertype:"string" format:"date-time"` // Start of time interval, quoted RFC 3339 format.
End *time.Time `json:"end,omitempty" swaggertype:"string" format:"date-time"` // End of time interval, quoted RFC 3339 format.
}

// CompareTime returns -1 if t is before the constraint interval, +1 if it is after,
Expand Down
Loading

0 comments on commit 63d713a

Please sign in to comment.