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 foundation for API development #1834

Closed
wants to merge 1 commit into from
Closed

Add foundation for API development #1834

wants to merge 1 commit into from

Conversation

louislam
Copy link
Owner

Description

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Just have a quick test, Swagger Autogen do a great job.

image

@louislam louislam linked an issue Jun 25, 2022 that may be closed by this pull request
@@ -58,7 +58,8 @@
"release-final": "node extra/update-version.js && npm run build-docker && node ./extra/press-any-key.js && npm run upload-artifacts && node ./extra/update-wiki-version.js",
"release-beta": "node extra/beta/update-version.js && npm run build && node ./extra/env2arg.js docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:$VERSION -t louislam/uptime-kuma:beta . --target release --push && node ./extra/press-any-key.js && npm run upload-artifacts",
"git-remove-tag": "git tag -d",
"build-dist-and-restart": "npm run build && npm run start-server-dev"
"build-dist-and-restart": "npm run build && npm run start-server-dev",
"swagger-autogen": "node ./extra/swagger.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add it into build script

@Computroniks
Copy link
Contributor

Computroniks commented Jun 25, 2022

It is probably a good idea to also serve the raw json file as well as the swagger UI. Something like api-docs/openapi.json. It just makes it more convenient for devs who want to process the spec in different ways.

@@ -0,0 +1,25 @@
/* npm run swagger-autogen */

const swaggerAutogen = require("swagger-autogen")();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const swaggerAutogen = require("swagger-autogen")();
const swaggerAutogen = require("swagger-autogen")({openapi: '3.0.0'});

Would it be possible to use openapi 3.0.0 instead of swagger 2.0?

};

// The working directory is root
const outputFile = "./swagger.json";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const outputFile = "./swagger.json";
const outputFile = "./openapi.json";

If 3.0.0 is used, it is suggested by the spec to use openapi.json as the file name

@@ -50,6 +52,13 @@ class UptimeKumaServer {
log.info("server", "Creating express and socket.io instance");
this.app = express();

// TODO swaggerDocument.host should be match current base url!
const swaggerDocument = require("../swagger.json");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const swaggerDocument = require("../swagger.json");
const swaggerDocument = require("../openapi.json");

Copy link
Contributor

@proffalken proffalken left a comment

Choose a reason for hiding this comment

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

Will this PR also provide the ability to create new services, or is it just the GET endpoints for now?

@ncecere
Copy link

ncecere commented Jul 19, 2022

As soon as the api is available I plan to start a terraform provider.

@bluepuma77 bluepuma77 mentioned this pull request Jul 30, 2022
@openstep
Copy link

Does this mean Uptime Kuma will have an api to create new monitors?

@louislam louislam marked this pull request as draft January 1, 2023 07:58
@Saibamen
Copy link
Contributor

@rafaribe: You can follow any GitHub issue by clicking Subscribe button on the right, without notifying anybody about your spam message ;)

image

@louislam
Copy link
Owner Author

louislam commented Dec 3, 2023

Move to #3854

@louislam louislam closed this Dec 3, 2023
@CommanderStorm CommanderStorm deleted the swagger branch December 14, 2023 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API functionality
6 participants