Как получить схему для API с помощью URL-адреса swagger. json и упоминания $ ref? - PullRequest
0 голосов
/ 03 августа 2020

Currenlty Я использую RestSharp для выполнения тестирования API .. И я хотел проверить схему API. Однако я хотел проверить, возможно ли это, поскольку мы используем swagger для получения схемы API, который я тестирую с помощью swagger. json url «$ ref»: «# / components / schemas / APICall»

Здесь я написал простой код Restsharp, чтобы поразить чванство. json URL. Я хочу извлечь схему отсюда .. Как я могу это сделать

      [Test]
        public void GetSchema()
        {
            var client = new RestClient("http://exampleAPI/swagger/v1/swagger.json");
            var request = new RestRequest(Method.GET);
            var repsonse = client.Execute(request);
            string json = repsonse.Content;
            System.Console.WriteLine(json);
        }


//Here is the part of the Json I get back I am trying to validate the GetAllTags Api schema.. but I am not able to find the response model...
{
  "openapi": "3.0.1",
  "info": {
    "title": "Example Api"
  },
 "path": {
"/api/Tag/GetAllTags": {
      "get": {
        "tags": [
          "Tag"
        ],
        "summary": "GetAllTags method is used to get all tags,
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Tag"
                  }
                }
              }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...