Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the start of the swagger documentation for the HELICS REST API #2289

Merged
merged 15 commits into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def ext_candidates(fpath):
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting",
"breathe",
"sphinxcontrib.redoc",
]

myst_enable_extensions = [
Expand Down Expand Up @@ -170,6 +171,18 @@ def ext_candidates(fpath):
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# redoc config
redoc = [
{
"name": "HELICS REST API",
"page": "references/api-reference/rest_queries_api",
Copy link
Member

@nightlark nightlark Mar 25, 2022

Choose a reason for hiding this comment

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

I think it would be better to generate this in the "top-level" swagger folder, similar to how the generated doxygen stuff is under a doxygen folder rather than nested under references/api-references.

Suggested change
"page": "references/api-reference/rest_queries_api",
"page": "swagger",

And then also add a directive to RTD saying to include the contents of the swagger folder so that all the yaml/json specs and model files are copied to the website. Using a separate top-level "swagger" folder for the generated swagger docs should also help prevent accidentally including all of the raw markdown folders in the published RTD site.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nightlark, If you think you know how to get this working, be my guest. I'm kind of guessing at how to get all the pathing right.

Copy link
Member

Choose a reason for hiding this comment

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

I need to look into the redoc settings, but I think the original pathing and generated swagger files were fine. The two issues I think for why it didn't work are:

  • RTD conf.py needs to specify that the swagger folder with model yaml files be included in the deployed site; embed is set to True for redoc, so it stores a copy of queries.yaml in the generated api page but the stored copy has paths referring to the other yaml files which aren't included on the RTD site
  • embed should probably be left as the default value False, making so that the relative paths in queries.yaml point to the right place; when queries.yaml is embedded it looks like the generated in an arbitrary folder that breaks the relative paths

I'll see if I can try to get it working later today or tonight, if it isn't already working.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll rollback to the an earlier version and try just turning embed off.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do think the swagger folder needs to end up in the api-reference folder but we can tweak that once we get things working.

Copy link
Member

@nightlark nightlark Mar 25, 2022

Choose a reason for hiding this comment

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

The swagger folder doesn't need to end up in api-reference (we'll treat it the same as we do the doxygen folder).

https://github.com/GMLC-TDC/HELICS/blob/swagger/docs/conf.py#L104
I think changing this line from:

html_extra_path = [os.path.abspath(os.path.join(doxygen_build_dir, "docs", "html"))]

to:

html_extra_path = ["swagger", os.path.abspath(os.path.join(doxygen_build_dir, "docs", "html"))]

should make so that the swagger folder gets included in the deployed site.

Copy link
Member

@nightlark nightlark Mar 25, 2022

Choose a reason for hiding this comment

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

From my (current) understanding of how redoc works, it looks like reverting the changes back to commit ded62ea, making the html_extra_path change, and turning embed off could work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, this link still returns a 404. I'll see if I come up with any other great ideas.

Copy link
Member

@nightlark nightlark Mar 25, 2022

Choose a reason for hiding this comment

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

Yeah -- it looks like https://docs.helics.org/en/swagger/swagger/models/Filter.yaml doesn't exist, so I think it didn't copy the folder. Might be that the absolute path to the swagger folder needs to be given instead to make RTD include it... or relative paths are to something like the repository root instead rather than the docs subfolder.

Another interesting observation from your link, it looks like turning off embed makes it look for the specs in some _specs folder. Kinda strange.

"spec-root": "swagger/",
"spec": "reference/queries.yaml",
"embed": False,
}
]


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
2 changes: 2 additions & 0 deletions docs/references/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
## [Python API](https://python.helics.org/api/)

## [Julia API](https://gmlc-tdc.github.io/HELICS.jl/latest/api/)

## [REST Queries API](./rest_queries_api.md)
3 changes: 3 additions & 0 deletions docs/references/api-reference/rest_queries_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# REST Queries API

The latest generated REST Queries API docs can be found at [https://docs.helics.org/en/latest/references/api-reference/rest_queries_api.html](https://docs.helics.org/en/latest/references/api-reference/rest_queries_api.html)
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ nbsphinx==0.8.7
breathe==4.31.0
sphinxcontrib-svg2pdfconverter==1.1.1
requests==2.26.0
gmlc-tdc-sphinxcontrib-redoc==1.6.1a1
3 changes: 3 additions & 0 deletions docs/swagger/docs/HELICS-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# HELICS-api

The Documentation for the REST API and JSON interfaces for HELICS
35 changes: 35 additions & 0 deletions docs/swagger/models/BrokerCreation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
title: BrokerCreation
type: object
properties:
type:
type: string
description: the HELICS core type to use when creating a broker
CoreType:
type: string
description: same as type
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know what "same as type" means.

core_type:
type: string
description: same as type
args:
type: string
description: extra command line arguments for the broker
num_feds:
type: number
num_brokers:
type: number
port:
type: string
host:
type: string
interface:
type: string
description: same as host
log_level:
type: string
description: helics logging level to use on the broker
uuid:
type: string
description: the uuid to use for the broker
broker_uuid:
type: string
description: the uuid to use for the broker
20 changes: 20 additions & 0 deletions docs/swagger/models/CoreConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
title: CoreConfig
type: object
properties:
autobroker:
type: boolean
localport:
type: string
debugging:
type: boolean
observer:
type: boolean
json:
type: boolean
profiler:
type: boolean
brokerkey:
type: string
brokerinitstring:
type: string
description: File configuration for the CoreConfiguration
3 changes: 3 additions & 0 deletions docs/swagger/models/FederateConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: FederateConfig
$ref: ""
description: ""
60 changes: 60 additions & 0 deletions docs/swagger/models/FederateInfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
title: FederateInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to be a beast, right? So many options to support or do we have a better way?

Copy link
Member Author

Choose a reason for hiding this comment

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

All the specific options that are not flags are listed already. I will probably expand this later to include the flags.
This is eventually meant to document the json configuration files but not fully there yet.

type: object
properties:
name:
type: string
core:
type: string
force_new_core:
type: boolean
coretype:
type: string
corename:
type: string
coreinitstring:
type: string
offset:
type:
- string
- number
period:
type:
- string
- number
timedelta:
type:
- string
- number
rtlag:
type:
- string
- number
rtlead:
type:
- string
- number
rttolerance:
type:
- string
- number
inputdelay:
type:
- string
- number
outputdelay:
type:
- string
- number
granttimeout:
type:
- string
- number
maxiteration:
type: integer
loglevel:
type: string
separator:
type: string
flags:
type: string
description: Properties applying to the federate and its creation
56 changes: 56 additions & 0 deletions docs/swagger/models/Filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
title: Filter
description: Configuration for a Filter
allOf:
- type: object
properties:
name:
type: string
inputType:
type: string
outputType:
type: string
cloning:
type: boolean
operation:
type: string
delivery:
type: string
sourcetargets:
type:
- string
- array
items:
type: string
destinationtargets:
type:
- string
- array
items:
type: string
properties:
oneOf:
- type: array
items:
type: object
properties:
name:
type: string
value:
type:
- string
- number
required:
- name
- value
- type: object
properties:
name:
type: string
value:
type:
- string
- number
required:
- name
- value
- $ref: ./interfaceOptions.yaml
14 changes: 14 additions & 0 deletions docs/swagger/models/FilterOptions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: FilterOptions
description: Configuration options for a filter
anyOf:
- type: object
properties:
flags:
type:
- string
- array
items:
type: string
"":
type: string
- $ref: ./interfaceOptions.yaml
6 changes: 6 additions & 0 deletions docs/swagger/models/Publication.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: Publication
type: object
properties:
id:
type: string
description: Configuration for a HELICS publication
3 changes: 3 additions & 0 deletions docs/swagger/models/address_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: address_query
type: string
description: return the connection address for the query target
28 changes: 28 additions & 0 deletions docs/swagger/models/base_response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: Common information shared across many responses
type: object
x-examples:
example-1:
name: string
id: 1
parent: 0
properties:
name:
type: string
minLength: 1
uuid:
type: string
minLength: 1
description: If the object is defined as uuid like it will contain the uuid as a field
id:
type: number
parent:
type: number
description: All objects except root broker will have a parent
required:
- name
- id
examples:
- name: string
uuid: string
id: 0
parent: 0
13 changes: 13 additions & 0 deletions docs/swagger/models/base_status_info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: base_status_info
type: object
properties:
id:
type: integer
"":
type: string
state:
type: string
required:
- id
- ""
- state
5 changes: 5 additions & 0 deletions docs/swagger/models/brokers_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: brokers_query
type: array
description: return a list of the children brokers for a target
items:
type: string
36 changes: 36 additions & 0 deletions docs/swagger/models/counts_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
description: return counts of the objects and interfaces under an object
type: object
x-examples:
example-1:
name: object_name
parent: 1
brokers: 3
federates: 4
countable_federates: 3
interfaces: 34
examples:
- name: string
id: 1
parent: 0
brokers: 0
federates: 0
countable_federates: 0
interfaces: 0
title: ""
properties:
brokers:
type: number
federates:
type: number
countable_federates:
type: number
interfaces:
type: number
object:
$ref: ./base_response.yaml
required:
- brokers
- federates
- countable_federates
- interfaces
- object
21 changes: 21 additions & 0 deletions docs/swagger/models/current_state_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
title: current_state_query
type: object
properties:
object:
$ref: ./base_response.yaml
state:
type: string
status:
type: boolean
federates:
type: array
items:
$ref: ./base_status_info.yaml
cores:
type: array
items:
$ref: ./base_status_info.yaml
brokers:
type: array
items:
$ref: ./base_status_info.yaml
5 changes: 5 additions & 0 deletions docs/swagger/models/current_time_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: current_time_query
type: object
properties:
id:
type: string
17 changes: 17 additions & 0 deletions docs/swagger/models/data_flow_graph_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: data_flow_graph_query
type: object
properties:
object:
$ref: ./base_response.yaml
brokers:
type: array
items:
$ref: ./data_flow_graph_query.yaml
cores:
type: array
items:
$ref: ./data_flow_graph_query.yaml
federates:
type: array
items:
$ref: ./data_flow_graph_query.yaml
13 changes: 13 additions & 0 deletions docs/swagger/models/dependencies_query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: dependencies_query
type: object
properties:
object:
$ref: ./base_response.yaml
dependents:
type: array
items:
type: integer
dependencies:
type: array
items:
type: integer
Loading