Skip to content

Commit

Permalink
Generate OpenAPI yaml via jsonnet for easier maintainability.
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingtonbear committed Oct 10, 2024
1 parent ecea4e7 commit 661467d
Show file tree
Hide file tree
Showing 11 changed files with 1,931 additions and 846 deletions.
1,772 changes: 926 additions & 846 deletions docs/openapi.yaml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions docs/src/lib/delete.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
parameters: [],
responses: {
'204': {
description: 'Success',
},
'404': {
description: 'File does not exist.',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
'405': {
description: 'Your path references a directory instead of a file; this request method is valid only for updating files.\n',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
},
}
24 changes: 24 additions & 0 deletions docs/src/lib/get.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
parameters: [],
responses: {
'200': {
description: 'Success',
content: {
'text/markdown': {
schema: {
type: 'string',
example: '# This is my document\n\nsomething else here\n',
},
},
'application/vnd.olrapi.note+json': {
schema: {
'$ref': '#/components/schemas/NoteJson',
},
},
},
},
'404': {
description: 'File does not exist',
},
},
}
95 changes: 95 additions & 0 deletions docs/src/lib/patch.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
parameters: [
{
name: 'Heading',
'in': 'header',
description: 'Name of heading relative to which you would like your content inserted. May be a sequence of nested headers delimited by "::".\n',
required: true,
schema: {
type: 'string',
},
},
{
name: 'Content-Insertion-Position',
'in': 'header',
description: 'Position at which you would like your content inserted; valid options are "end" or "beginning".\n',
schema: {
type: 'string',
enum: [
'end',
'beginning',
],
default: 'end',
},
},
{
name: 'Content-Insertion-Ignore-Newline',
'in': 'header',
description: 'Insert content before any newlines at end of header block.\n',
schema: {
type: 'string',
enum: [
true,
false,
],
default: false,
},
},
{
name: 'Heading-Boundary',
'in': 'header',
description: 'Set the nested header delimiter to a different value. This is useful if "::" exists in one of the headers you are attempting to use.\n',
schema: {
type: 'string',
default: '::',
},
},
],
requestBody: {
description: 'Content you would like to insert.',
required: true,
content: {
'text/markdown': {
schema: {
type: 'string',
example: '# This is my document\n\nsomething else here\n',
},
},
},
},
responses: {
'200': {
description: 'Success',
},
'400': {
description: 'Bad Request; see response message for details.',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
'404': {
description: 'Does not exist',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
'405': {
description: 'Your path references a directory instead of a file; this request method is valid only for updating files.\n',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
},
}
10 changes: 10 additions & 0 deletions docs/src/lib/path.param.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
name: 'filename',
'in': 'path',
description: 'Path to the relevant file (relative to your vault root).\n',
required: true,
schema: {
type: 'string',
format: 'path',
},
}
17 changes: 17 additions & 0 deletions docs/src/lib/period.param.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
name: 'period',
'in': 'path',
description: 'The name of the period for which you would like to grab the current note.',
required: true,
schema: {
type: 'string',
enum: [
'daily',
'weekly',
'monthly',
'quarterly',
'yearly',
],
default: 'daily',
},
}
40 changes: 40 additions & 0 deletions docs/src/lib/post.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
parameters: [],
requestBody: {
description: 'Content you would like to append.',
required: true,
content: {
'text/markdown': {
schema: {
type: 'string',
example: '# This is my document\n\nsomething else here\n',
},
},
},
},
responses: {
'204': {
description: 'Success',
},
'400': {
description: 'Bad Request',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
'405': {
description: 'Your path references a directory instead of a file; this request method is valid only for updating files.\n',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
},
}
49 changes: 49 additions & 0 deletions docs/src/lib/put.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
tags: [
'Active File',
],
summary: 'Update the content of the active file open in Obsidian.\n',
parameters: [],
requestBody: {
description: 'Content of the file you would like to upload.',
required: true,
content: {
'text/markdown': {
schema: {
type: 'string',
example: '# This is my document\n\nsomething else here\n',
},
},
'*/*': {
schema: {
type: 'string',
},
},
},
},
responses: {
'204': {
description: 'Success',
},
'400': {
description: "Incoming file could not be processed. Make sure you have specified a reasonable file name, and make sure you have set a reasonable 'Content-Type' header; if you are uploading a note, 'text/markdown' is likely the right choice.\n",
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
'405': {
description: 'Your path references a directory instead of a file; this request method is valid only for updating files.\n',
content: {
'application/json': {
schema: {
'$ref': '#/components/schemas/Error',
},
},
},
},
},
}
Loading

0 comments on commit 661467d

Please sign in to comment.