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

API Documentation fixes #2086

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/api/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(sources
hex/specs/search.yaml
hex/specs/stats.yaml
hex/specs/teleporter.yaml
hex/specs/localdns.yaml
docs.c
)

Expand Down
2 changes: 0 additions & 2 deletions src/api/docs/content/specs/clients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ components:
schema:
allOf:
- $ref: 'clients.yaml#/components/schemas/clients/put'
- $ref: 'common.yaml#/components/schemas/took'
responses:
'201':
description: Created item
Expand Down Expand Up @@ -170,7 +169,6 @@ components:
schema:
allOf:
- $ref: 'clients.yaml#/components/schemas/clients/post'
- $ref: 'common.yaml#/components/schemas/took'
responses:
'201':
description: Created item
Expand Down
2 changes: 1 addition & 1 deletion src/api/docs/content/specs/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ components:
example: 1672580025
until:
in: query
description: Unix timestamp from when the data should be requested
description: Unix timestamp until when the data should be requested
name: until
schema:
type: integer
Expand Down
11 changes: 5 additions & 6 deletions src/api/docs/content/specs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ components:
get:
summary: Get current configuration of your Pi-hole
tags:
- "Pi-hole Configuration"
- "Pi-hole configuration"
operationId: "get_config"
description: |
This API hook returns infos about the config of your Pi-hole.
Expand Down Expand Up @@ -34,7 +34,7 @@ components:
patch:
summary: Change configuration of your Pi-hole
tags:
- "Pi-hole Configuration"
- "Pi-hole configuration"
operationId: "patch_config"
description: |
This API hook allows to modify the config of your Pi-hole. This endpoint supports changing multiple properties at once when you specify several in the payload. See examples below.
Expand All @@ -45,7 +45,6 @@ components:
schema:
allOf:
- $ref: 'config.yaml#/components/schemas/config'
- $ref: 'common.yaml#/components/schemas/took'
examples:
config_one:
$ref: 'config.yaml#/components/examples/config_one'
Expand Down Expand Up @@ -77,7 +76,7 @@ components:
get:
summary: Get specific part of current configuration of your Pi-hole
tags:
- "Pi-hole Configuration"
- "Pi-hole configuration"
operationId: "get_config_elem"
description: |
This API hook returns infos about the requested subset of your Pi-hole's configuration.
Expand All @@ -100,7 +99,7 @@ components:
put:
summary: Add config array item
tags:
- "Pi-hole Configuration"
- "Pi-hole configuration"
operationId: "add_array_item"
description: |
*Note:* There will be no content on success.
Expand Down Expand Up @@ -134,7 +133,7 @@ components:
delete:
summary: Delete config array item
tags:
- "Pi-hole Configuration"
- "Pi-hole configuration"
operationId: "delete_array_item"
description: |
*Note:* There will be no content on success.
Expand Down
1 change: 0 additions & 1 deletion src/api/docs/content/specs/domains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ components:
schema:
allOf:
- $ref: 'domains.yaml#/components/schemas/domains/put'
- $ref: 'common.yaml#/components/schemas/took'
responses:
'201':
description: Created domain
Expand Down
199 changes: 199 additions & 0 deletions src/api/docs/content/specs/localdns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
openapi: 3.0.2
components:
paths:
record_type:
parameters:
- $ref: 'localdns.yaml#/components/parameters/record_type'
get:
summary: Get local DNS records
tags:
- "Local DNS Records"
security: []
irsheep marked this conversation as resolved.
Show resolved Hide resolved
operationId: "get_records"
description: |
Get local DNS records (A or CNAME).
responses:
'200':
description: OK
content:
application/json:
schema:
allOf:
- $ref: 'localdns.yaml#/components/schemas/record_type'
- $ref: 'common.yaml#/components/schemas/took'
'401':
description: Unauthorized
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/unauthorized'
- $ref: 'common.yaml#/components/schemas/took'

host_value:
parameters:
- $ref: 'localdns.yaml#/components/parameters/host_value'
put:
summary: Add a host record
tags:
- "Local DNS Records"
operationId: "add_host_record"
description: |
Add a 'host' (A or AAAA) DNS record to the Pi-hole hosts file.
responses:
'201':
description: Created item
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/schemas/took'
'401':
description: Unauthorized
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/unauthorized'
- $ref: 'common.yaml#/components/schemas/took'
delete:
summary: Delete a host record
tags:
- "Local DNS Records"
operationId: "delete_host_record"
description: |
Remove a host DNS record from the hosts file.
responses:
'204':
description: No Content (deleted)
'400':
description: Bad request
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/bad_request'
- $ref: 'common.yaml#/components/schemas/took'
'401':
description: Unauthorized
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/unauthorized'
- $ref: 'common.yaml#/components/schemas/took'
'404':
description: Item not found
content:
application/json:
schema:
$ref: 'common.yaml#/components/schemas/took'

cname_value:
parameters:
- $ref: 'localdns.yaml#/components/parameters/cname_value'
put:
summary: Add a CNAME record
tags:
- "Local DNS Records"
operationId: "add_cname_value"
description: |
Add a CNAME DNS record to the Pi-hole dnsmaq.conf file.
responses:
'201':
description: Created item
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/schemas/took'
'400':
description: Bad request
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/bad_request'
- $ref: 'common.yaml#/components/schemas/took'
'401':
description: Unauthorized
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/unauthorized'
- $ref: 'common.yaml#/components/schemas/took'
delete:
summary: Delete a CNAME record
tags:
- "Local DNS Records"
operationId: "delete_cname_value"
description: |
Delete a local 'CNAME' DNS record
responses:
'204':
description: No Content (deleted)
'401':
description: Unauthorized
content:
application/json:
schema:
allOf:
- $ref: 'common.yaml#/components/errors/unauthorized'
- $ref: 'common.yaml#/components/schemas/took'
'404':
description: Item not found
content:
application/json:
schema:
$ref: 'common.yaml#/components/schemas/took'

parameters:
record_type:
in: path
name: type
schema:
type: string
enum:
- hosts
- cnameRecords
required: true
description: The type of DNS record hosts (A) or cnameRecord (CNAME)
example: hosts
host_value:
in: path
name: record
schema:
type: string
required: true
description: The IP address (IPv4 or IPv6) and domain seperated by a 'SPACE'

Check failure on line 169 in src/api/docs/content/specs/localdns.yaml

View workflow job for this annotation

GitHub Actions / spell-check

seperated ==> separated
irsheep marked this conversation as resolved.
Show resolved Hide resolved
example: 8.8.8.8 googledns.com
cname_value:
in: path
name: record
schema:
type: string
required: true
description: A CSV string with domain, target doomain and TTL
example: example.net,pi-hole.net,60

schemas:
record_type:
type: object
properties:
config:
type: object
properties:
dns:
type: object
properties:
# cnameRecords:
# type: array
# items:
# type: string
# example: ["pi.hole,pi-hole.net,60"]
hosts:
type: array
items:
type: string
example: ["192.168.0.1 mygateway.local"]
4 changes: 2 additions & 2 deletions src/api/docs/content/specs/logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ components:
- $ref: 'common.yaml#/components/schemas/took'
ftl:
get:
summary: Get DNS log content
summary: Get FTL information
tags:
- "FTL information"
operationId: "get_ftl_log"
Expand Down Expand Up @@ -70,7 +70,7 @@ components:
- $ref: 'common.yaml#/components/schemas/took'
webserver:
get:
summary: Get DNS log content
summary: Get HTTP server information
tags:
- "FTL information"
operationId: "get_webserver_log"
Expand Down
13 changes: 11 additions & 2 deletions src/api/docs/content/specs/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ tags:
description: Methods used to trigger certain actions on your Pi-hole
- name: "PADD"
description: Methods used to query Pi-hole from PADD


- name: "Local DNS Records"
description: Methods used to manage A and CNAME records

paths:
/auth:
Expand Down Expand Up @@ -228,6 +228,15 @@ paths:
/config:
$ref: 'config.yaml#/components/paths/config'

/config/dns/{type}:
$ref: 'localdns.yaml#/components/paths/record_type'

/config/dns/hosts/{record}:
$ref: 'localdns.yaml#/components/paths/host_value'

/config/dns/cnameRecords/{record}:
$ref: 'localdns.yaml#/components/paths/cname_value'

/config/{element}:
$ref: 'config.yaml#/components/paths/config_elem'

Expand Down
5 changes: 3 additions & 2 deletions src/api/docs/content/specs/queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ components:
parameters:
- in: query
name: from
description: Get queries from...
description: Unix timestamp from when the data should be requested
required: false
schema:
type: number
- in: query
name: until
description: Get queries until...
description: Unix timestamp until when the data should be requested
required: false
schema:
type: number
Expand Down Expand Up @@ -114,6 +114,7 @@ components:
description: Load queries from on-disk database rather than from in-memory
required: false
schema:
type: boolean
enum:
- true
- false
irsheep marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 6 additions & 0 deletions src/api/docs/docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
#include "hex/specs/padd.yaml"
};

static const unsigned char specs_localdns_yaml[] = {
#include "hex/specs/localdns.yaml"
github-advanced-security[bot] marked this conversation as resolved.
Dismissed
Show resolved Hide resolved
};


struct {
const char *path;
const char *mime_type;
Expand Down Expand Up @@ -173,6 +178,7 @@
{"specs/teleporter.yaml", "text/plain", (const char*)specs_teleporter_yaml, sizeof(specs_teleporter_yaml)},
{"specs/action.yaml", "text/plain", (const char*)specs_action_yaml, sizeof(specs_action_yaml)},
{"specs/padd.yaml", "text/plain", (const char*)specs_padd_yaml, sizeof(specs_padd_yaml)},
{"specs/localdns.yaml", "text/plain", (const char*)specs_localdns_yaml, sizeof(specs_localdns_yaml)},
};

#endif // API_DOCS_H
Loading