I am using open api 3.0 . I am designing a endpoint which has a path param : implemented spec in mule 4.4
paths:
/comps/{compId}/emps/{empId}:
get:
parameters:
- name: compId
in: path
required: true
schema:
type: string
minLength: 1
- name: empId
in: path
required: true
schema:
type: string
minLength: 1
However if I make the following request , ( notice that 'compId' is a empty string with a space ) it is not getting validated ? I am sure this should be possible in openapi to enforce not null not empty string ?
http://localhost:8081/v2/comps/ /emps/123
I believe that your expectation is incorrect. An empty string ("") and an a string containing a space (" ") are two different things. In most programming languages the string containing a single space will be considered a perfectly valid string of length 1.
If you want to add a validation to avoid that you may be able use a pattern
property for the string and declare a regular expression to validate valid strings. For example something like: "pattern": "^[A-Za-z0-9]+$"
.