Project: KICS (Provisioning / Security & Compliance)
File: 8d0921d6-4131-461f-a253-99e873f8f77e.md

title: Server URL Uses Undefined Variables hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 8d0921d6-4131-461f-a253-99e873f8f77e Query name: Server URL Uses Undefined Variables Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Any variable used in the Service URL should be defined in the Service Object through 'variables'.<br> ```json title="Positive test num. 1 - json file" hl_lines="30" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "summary": "List API versions", "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "address": { "server": { "url": "https://development.{server}.com/{base}" } } } } }, "operationId": "listVersionsv2" } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="32" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "properties": { "uuid": { "type": "string", "format": "uuid" } }, "type": "object" } } } } }, "servers": [ { "url": "https://development.{server}.com/{base}", "description": "Development server", "variables": { "base": { "default": "v2" } } } ] } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="24" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: # the unique user id type: string format: uuid links: address: server: url: https://development.{server}.com/{base} ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="22" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: the user being returned content: application/json: schema: type: object properties:

# the unique user id type: string format: uuid servers: url: https://development.{server}.com/{base} description: Development server variables: base: default: v2 ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "summary": "List API versions", "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "address": { "server": { "url": "https://development.{server}.com/{base}", "variables": { "base": { "default": "v2" }, "server": { "default": "gigant-server" } } } } } } }, "operationId": "listVersionsv2" } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "properties": { "uuid": { "type": "string", "format": "uuid" } }, "type": "object" } } } } }, "servers": [ { "url": "https://development.{server}.com/{base}", "description": "Development server", "variables": { "base": { "default": "v2" }, "server": { "default": "gigant-server" } } } ] } } } } ``` ```yaml title="Negative test num. 3 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: # the unique user id type: string format: uuid links: address: server: url: https://development.{server}.com/{base} variables: base: default: v2 server: default: gigant-server ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: # the unique user id type: string format: uuid servers: url: https://development.{server}.com/{base} description: Development server variables: base: default: v2 server: default: gigant-server ``` </details>