GithubHelp home page GithubHelp logo

Comments (7)

ranacseruet avatar ranacseruet commented on May 28, 2024

@marbemac , feel free to review when you have a moment and add anything you think might be missing.

from api-spec-converter.

marbemac avatar marbemac commented on May 28, 2024

I think that's most of it. A while back, either in slack or TP, we were sending around swagger specs w stoplight extensions. Think you could dig up the one we decided on in the end? I think that has everything in it, plus naming and organization.

from api-spec-converter.

ranacseruet avatar ranacseruet commented on May 28, 2024

Sure, here is the example format you came up with as I found on slack. Adding it here for reference:

{
  "swagger": "2.0",
  "host": "http://localhost:3000",  
  "basePath": "",
  "info": {
    "version": "",
    "title": "TODO",
    "description": "# Welcome\n\nThis is a place to put general notes and extra information about your project / API.\n\nClick on the edit icon in the top left to change this content.\n\nCheck out the video below, or get started right away by choosing an environment from the list\non the left.\n\n::: meta\n  ### Tips\n\n  You can use the meta markdown directive to add sidebar content (on large screens).\n\n  ### Useful Links\n  - [Getting Started](/docs/designer/#getting-started)\n  - [Markdown Reference](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)\n  - [StopLight Markdown Directives](/docs/designer/#markdown)\n:::\n\n@[vimeo](147427619)\n\n# Section 2\n\nH1 titles automatically create new sections.\n\n::: meta\n  Meta content gets put into the sidebar of its parent section.\n:::"
  },
  "paths": {
    "/api/task_lists": {
      "parameters": [],
      "get": {
        "responses": {},
        "parameters": [],
        "consumes": [
          "application/json"
        ],
        "produces": [],
        "operationId": "",
        "summary": "",
        "description": ""
        "x-stoplight-before": "function (ctx, request) {\n  // For example, adding ?mock=200 to a request url will enable mocking,\n  // using the example endpoint response for the 200 status code.\n  var mock = request.url.query.get(\"mock\")\n  if (mock) {\n    ctx.mock.set(true, mock)\n  }\n}",
        "x-stoplight-after": "function (ctx, request) {\n  // For example, adding ?mock=200 to a request url will enable mocking,\n  // using the example endpoint response for the 200 status code.\n  var mock = request.url.query.get(\"mock\")\n  if (mock) {\n    ctx.mock.set(true, mock)\n  }\n}",
        "x-stoplight-mock": false
      }
    }
  },
  "definitions": {},
  "x-stoplight": {
    "before": "function(ctx, request) {\n  // This runs your endpoint middleware before script, if applicable.\n  // Removing this means your endpoint before scripts will not be run!\n  SL.runEndpoint();\n}",
    "after": "function(ctx, request, response) {\n  // This runs your endpoint middleware after script, if applicable.\n  // Removing this means your endpoint after scripts will not be run!\n  SL.runEndpoint();\n}",
    "proxy": {
      "port": "4010",
      "startupMessage": "",
      "log": true,
      "learn": false,
      "mock": false,
      "debug": true
    }
    "functions": [
      {
        "name": "queryStringMocking",
        "description": "This extends the basic mocking functionality, and makes it possible to control mocking behavior via the request query string.",
        "script": "function (ctx, request) {\n  // For example, adding ?mock=200 to a request url will enable mocking,\n  // using the example endpoint response for the 200 status code.\n  var mock = request.url.query.get(\"mock\")\n  if (mock) {\n    ctx.mock.set(true, mock)\n  }\n}"
      },
      {
        "name": "onlyProcessPath",
        "description": "If your API lives at a subpath, for example, localhost:3000/api, then this function is useful to only learn / log requests that match the given subpath.",
        "script": "function (ctx, request, subpath) {\n  // for example, onlyProcessPath(ctx, request, \"api\") will turn off logging/learning for any\n  // requests that don't have \"api\" in their path.\n  if (request.url.path.get().indexOf(subpath) == -1) {\n     ctx.log.set(false)\n     ctx.learn.set(false)\n  }\n}"
      },
      {
        "name": "addRandomLatency",
        "description": "Sleep for a random amount of time. Useful to simulate latency.",
        "script": "function (min, max) {\n  SL.sleep(SL.rand(min, max))\n}"
      },
      {
        "name": "validateResponse",
        "description": "Calling this function will validate the response.",
        "script": "function (ctx, response) {\n  var messages = response.validate();\n      \n  if (!response.valid.get()) {\n    // If mocking is enabled and validation fails, this means \n    // the example mock we've set for this endpoint/status code \n    // does not match the schema.. we don't want developers working \n    // off of an invalid example, so here we ovewrite the response\n    // with the the validation error messages.\n    if (ctx.mock.enabled.get()) {\n      response.body.set(messages)\n    }\n  }\n}"
      },
      {
        "name": "validateRequest",
        "description": "Calling this function will validate the request. Uncomment the line indicated in the script to add helpful validation errors to your api calls.",
        "script": "function (ctx, request) {\n  var messages = request.validate();\n  \n  if (!request.valid.get()) {\n    // Uncomment the line below to respond immediately\n    // with the validation error messages. Useful to let\n    // developers know exactly what is wrong with their API request.\n\n    // request.hijack(400, \"application/json\", messages)\n  }\n}"
      }
    ],
    "groupings": {
      "endpoints": []
    }
  }
}

from api-spec-converter.

marbemac avatar marbemac commented on May 28, 2024

what do you think? anything missing or need to be re-considered?

from api-spec-converter.

ranacseruet avatar ranacseruet commented on May 28, 2024

Sounds OK to me. Apparently, don't see a problem atm. I will let you know if something come up in the way.

from api-spec-converter.

ranacseruet avatar ranacseruet commented on May 28, 2024

@marbemac , I have updated this package version on our app, which will include this feature (along with oauth2 security updates as well).

I also have re-enabled import/export option for stoplight as well. Seems to be working for me. Please verify from your side.

from api-spec-converter.

ranacseruet avatar ranacseruet commented on May 28, 2024

This is already done. Closing it.

from api-spec-converter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.