Comments (7)
What do you have baseUrl for in this case? Swagger spec explicitly says: All API endpoints are relative to the base URL
, so if your spec is structured otherwise, you are in a violation of spec.
from openapi-validator-middleware.
@hpl002 Wait, it should be the other way around. You can add api/
as baseUrl in your spec and it will be concatted automatically when doing the matching.
Would be easier to understand situation if you shared (potentially with scrambled names) relevant fragments of your spec.
from openapi-validator-middleware.
Thanks for getting back to me.
Here is a derivative of your pets.yaml spec
openapi: 3.0.0
servers:
- url: "https://api.paymentsos.com/"
info:
title: PaymentsOS API
version: 1.0.0
x-flow-proxies:
accounts:
target: http://localhost:3020
paths:
/accounts:
x-flow-proxy: accounts
get:
summary: get all pets
tags:
- pets
operationId: listPets
responses:
"200":
description: list of pets
headers:
x-zooz-request-id:
description: request id
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/pets"
components:
schemas:
error_model:
required:
- description
- category
properties:
category:
type: string
description: Error code.
description:
type: string
description: Error message for the developer.
more_info:
type: string
description: "More info about the error, can include link to the documentation."
pet:
description: pet
type: object
oneOf:
- $ref: "#/components/schemas/dog_object"
- $ref: "#/components/schemas/cat_object"
pet2:
description: pet
type: object
oneOf:
- $ref: "#/components/schemas/dog_object2"
- $ref: "#/components/schemas/cat_object"
pets:
type: array
items:
$ref: "#/components/schemas/pet"
pet-discriminator-on-child:
description: pet
type: object
required:
- pet
properties:
pet:
$ref: "#/components/schemas/pet-discriminator"
pet-discriminator:
description: pet
type: object
oneOf:
- $ref: "#/components/schemas/dog_object"
- $ref: "#/components/schemas/cat_object"
discriminator:
propertyName: type
pet-discriminator-multiple:
description: pet
type: object
oneOf:
- $ref: "#/components/schemas/dog_multiple"
- $ref: "#/components/schemas/cat_object"
discriminator:
propertyName: type
properties:
name:
type: string
required:
- name
pet-discriminator-mapping:
description: pet
type: object
oneOf:
- $ref: "#/components/schemas/dog_multiple"
- $ref: "#/components/schemas/cat_object"
discriminator:
propertyName: type
mapping:
mapped_dog: "#/components/schemas/dog_multiple"
mapped_cat: "#/components/schemas/cat_object"
properties:
name:
type: string
required:
- name
dog_object:
type: object
required:
- bark
properties:
bark:
type: string
dog_object2:
type: object
required:
- bark
properties:
bark:
type: string
enum:
- foo
- bar
dog_multiple:
type: object
required:
- dog_age
discriminator:
propertyName: model
oneOf:
- $ref: "#/components/schemas/small_dog"
- $ref: "#/components/schemas/big_dog"
properties:
dog_age:
type: string
cat_object:
type: object
required:
- fur
properties:
fur:
type: string
pattern: '^\d+$'
small_dog:
type: object
required:
- max_length
properties:
max_length:
type: string
big_dog:
type: object
required:
- min_length
properties:
min_length:
type: string
medium_dog:
type: object
required:
- min_length
- max_length
additionalProperties: false
properties:
max_length:
type: string
min_length:
type: string
if have to set basepath for use with my other middleware. This creates a conflict when calling
const methodSchema = schemaEndpointResolver.getMethodSchema(schemas, path, method)
paths in schemas and path do not align, thus resulting in undefined and no validation.
Edit:
Endpoints in schemas object are not prefixed with basepath
from openapi-validator-middleware.
And when you change server to
servers:
- url: "https://api.paymentsos.com/api"
that doesn't help?
from openapi-validator-middleware.
No,still same result.
Did however bypass this by just forecefully setting the baseurl to nothing before sending it in. Works, but not ideal..
return async (req, res, next) => {
const currBase = req.baseUrl;
req.baseUrl = "";
inputValidation.init(gatewayConfiguration.configPath);
inputValidation.validate(req, res, next);
req.baseUrl = currBase;
next();
};
}
from openapi-validator-middleware.
Feel free to close the issue is you're not planning to address it further. Forcefully setting the baseUrl works..
from openapi-validator-middleware.
no-no, I still need to look into it
from openapi-validator-middleware.
Related Issues (20)
- Unknown query parameters handling
- How to Validate multiple versions HOT 2
- Inconsistent body validation behavior HOT 5
- Internationalization HOT 3
- simple parent child spec fails HOT 3
- Invalid Server URL error HOT 1
- Regression? Express + OpenAPI 3.0 + Multer + multipart/form-data rejects valid file HOT 1
- Update lockfile to automatically remove the vulnerability introduced by validator HOT 1
- what is require('../../src/middleware') meant to reference? HOT 4
- Parameter Serialization support
- contentTypeValidation boolean not supported for Open API 3.0
- Validate Response - Express HOT 1
- OpenAPI v3.1 Support HOT 3
- Path trailing parameter not validated as required HOT 2
- Are there any plans to add support of response validation? HOT 1
- Not validating if there is required header or query param HOT 2
- Circular references not supported ?
- Fastify integration fails when using fastify-multipart
- the field validation works with openApi 3.0.0? HOT 2
- Is it maintained?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-validator-middleware.