Browse Source

Improve OpenAPI builder

Maurits van der Schee 5 years ago
parent
commit
0c0c9de507
2 changed files with 2 additions and 10 deletions
  1. 1
    5
      api.php
  2. 1
    5
      src/Tqdev/PhpCrudApi/OpenApi/OpenApiBuilder.php

+ 1
- 5
api.php View File

8175
             return sprintf('%s://%s%s/%s', $protocol, $host, $port, $path);
8175
             return sprintf('%s://%s%s/%s', $protocol, $host, $port, $path);
8176
         }
8176
         }
8177
 
8177
 
8178
-        public function build() /*: void */
8178
+        public function build(): OpenApiDefinition
8179
         {
8179
         {
8180
             $this->openapi->set("openapi", "3.0.0");
8180
             $this->openapi->set("openapi", "3.0.0");
8181
             if (!$this->openapi->has("servers") && isset($_SERVER['REQUEST_URI'])) {
8181
             if (!$this->openapi->has("servers") && isset($_SERVER['REQUEST_URI'])) {
8182
                 $this->openapi->set("servers|0|url", $this->getServerUrl());
8182
                 $this->openapi->set("servers|0|url", $this->getServerUrl());
8183
             }
8183
             }
8184
             $this->records->build();
8184
             $this->records->build();
8185
-        }
8186
-
8187
-        public function getDefinition(): OpenApiDefinition
8188
-        {
8189
             return $this->openapi;
8185
             return $this->openapi;
8190
         }
8186
         }
8191
     }
8187
     }

+ 1
- 5
src/Tqdev/PhpCrudApi/OpenApi/OpenApiBuilder.php View File

28
         return sprintf('%s://%s%s/%s', $protocol, $host, $port, $path);
28
         return sprintf('%s://%s%s/%s', $protocol, $host, $port, $path);
29
     }
29
     }
30
 
30
 
31
-    public function build() /*: void */
31
+    public function build(): OpenApiDefinition
32
     {
32
     {
33
         $this->openapi->set("openapi", "3.0.0");
33
         $this->openapi->set("openapi", "3.0.0");
34
         if (!$this->openapi->has("servers") && isset($_SERVER['REQUEST_URI'])) {
34
         if (!$this->openapi->has("servers") && isset($_SERVER['REQUEST_URI'])) {
35
             $this->openapi->set("servers|0|url", $this->getServerUrl());
35
             $this->openapi->set("servers|0|url", $this->getServerUrl());
36
         }
36
         }
37
         $this->records->build();
37
         $this->records->build();
38
-    }
39
-
40
-    public function getDefinition(): OpenApiDefinition
41
-    {
42
         return $this->openapi;
38
         return $this->openapi;
43
     }
39
     }
44
 }
40
 }

Loading…
Cancel
Save