Codey

Codey 路 Acciones GPT

Code Runner

  • POST /run_codeRun code
  • POST /save_codeSave code
  • GET /download/{filename}Download file
  • GET /helpHelp
  • GET /credit_limitGet Credits limit
  • POST /uploadUpload file with filename and data
  • POST /quick_chartCreate a quick chart
  • POST /show_snippetShow code snippet
Esquema original API
{
  "openapi": "3.0.1",
  "info": {
    "title": "Code Runner",
    "version": "1.2"
  },
  "servers": [
    {
      "url": "https://code-runner-plugin.vercel.app",
      "description": "Hosted server"
    }
  ],
  "paths": {
    "/run_code": {
      "post": {
        "summary": "Run code",
        "operationId": "runCode",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Code"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code output"
          }
        }
      }
    },
    "/save_code": {
      "post": {
        "summary": "Save code",
        "operationId": "saveCode",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeFile"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "download_link": {
                      "type": "string",
                      "example": "/download/hello_world.cpp"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/download/{filename}": {
      "get": {
        "summary": "Download file",
        "operationId": "downloadFile",
        "parameters": [
          {
            "name": "filename",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "hello_world.cpp"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File downloaded"
          }
        }
      }
    },
    "/help": {
      "get": {
        "summary": "Help",
        "operationId": "help",
        "responses": {
          "200": {
            "description": "Help",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/credit_limit": {
      "get": {
        "summary": "Get Credits limit",
        "operationId": "creditLimit",
        "responses": {
          "200": {
            "description": "Credits limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/upload": {
      "post": {
        "summary": "Upload file with filename and data",
        "operationId": "uploadFile",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FileData"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "File uploaded and saved in database",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "download_link": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quick_chart": {
      "post": {
        "summary": "Create a quick chart",
        "operationId": "quickChart",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "chart_type",
                  "labels",
                  "datasets"
                ],
                "properties": {
                  "chart_type": {
                    "type": "string",
                    "description": "The type of the chart."
                  },
                  "labels": {
                    "type": "string",
                    "description": "The labels for the chart."
                  },
                  "datasets": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "label",
                        "data"
                      ],
                      "properties": {
                        "label": {
                          "type": "string",
                          "description": "The label for the dataset."
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          },
                          "description": "The data for the dataset."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "Chart created",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "properties": {
                      "chart_link": {
                        "type": "string",
                        "description": "The link to the created chart."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/show_snippet": {
      "post": {
        "summary": "Show code snippet",
        "operationId": "showSnippet",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Snippet"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Snippet image showed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Code": {
        "type": "object",
        "required": [
          "code",
          "language"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The code to be run."
          },
          "language": {
            "type": "string",
            "description": "The programming language code."
          }
        }
      },
      "CodeFile": {
        "type": "object",
        "required": [
          "filename",
          "code"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The name of the file."
          },
          "code": {
            "type": "string",
            "description": "The code to be saved."
          }
        }
      },
      "FileData": {
        "type": "object",
        "required": [
          "filename",
          "data"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The name of the file."
          },
          "data": {
            "type": "string",
            "description": "The data to be uploaded."
          }
        }
      },
      "Snippet": {
        "type": "object",
        "required": [
          "code",
          "title",
          "theme",
          "language"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The code snippet."
          },
          "title": {
            "type": "string",
            "description": "The title for code snippet.",
            "example": "Prime Numbers",
            "message": "Title should be a string and if not provided, guess it from the code."
          },
          "theme": {
            "type": "string",
            "description": "The color theme of the code snippet.",
            "example": "Monokai",
            "message": "Available themes to pick from: alternight, css-variables, dark-plus, dracula-soft, dracula, github-dark-dimmed, github-dark, github-light, light-plus, material-darker, material-default, material-lighter, material-ocean, material-palenight, min-dark, min-light, minimus, monokai, nord, one-dark-pro, poimandres, slack-dark, slack-ochin, solarized-dark, solarized-light, vitesse-dark, vitesse-light."
          },
          "language": {
            "type": "string",
            "description": "The programming language of the code snippet."
          },
          "opacity": {
            "type": "number",
            "description": "The opacity of the background.",
            "minimum": 0,
            "maximum": 1,
            "default": 0.8
          },
          "blurLines": {
            "type": "string",
            "description": "Select the lines to blur.",
            "default": 0,
            "message": "Provide a string of line numbers separated by comma or start line to end line. Example: 1,3-5,7-10"
          },
          "showNums": {
            "type": "boolean",
            "description": "Whether to show line numbers.",
            "default": true
          }
        }
      }
    }
  }
}