-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Labels
kind/bugIndicates an issueIndicates an issue
Description
Actual Behavior
If a request parameter is missing or its datatype different from yaml schema, no error is raised
Expected Behavior
An error should be raised
Steps to Reproduce
Schema:
openapi: 3.0.1
info:
title: API Documentation
description: |
Welcome to the API documentation. This documentation provides an overview of the basic REST API functionalities. It will help you learn and understand how to use the API to get the data you need and develop integrations between your application and the platform.
The API allows you to:
* manage users
* manage reports
To work with most methods, you need to acquire an access token first:
<ol>
<li> Call <a href="#post-/auth/login">POST /auth/login</a> </li>
<li> Copy the "access_token" value from the response </li>
<li> Go to the "Authentication" section</li>
<li> Paste the value into the "api-token" field </li>
<li> Click the "set" button </li>
</ol>
termsOfService: 'https://example.com/termsOfService'
contact:
email: support@example.com
version: 1.0.0
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
servers:
- url: https://api.example.com/
tags:
- name: login
description: User login/logout
- name: general
description: General management
components:
schemas:
UserRequest:
type: object
oneOf:
- type: object
required: [ user_id ]
properties:
user_id:
type: integer
- type: object
required: [ username ]
properties:
username:
type: string
responses:
OkResponse:
description: Success.
content:
'application/json':
schema:
type: object
required: [ result ]
properties:
result:
type: string
enum: [ OK ]
BadRequestError:
description: Bad request.
content:
'application/json':
schema:
type: object
required: [ result ]
properties:
result:
type: string
enum: [ BAD_REQUEST ]
securitySchemes:
bearerAuth:
type: http
scheme: bearer
paths:
/auth/login:
post:
tags:
- login
summary: User login
description: Get an access token for authentication
operationId: login
parameters:
- name: access_token
in: query
description: OAuth2-provided access token
schema:
type: string
- name: username
in: query
description: User's username
schema:
type: string
- name: password
in: query
description: User's password
schema:
type: string
responses:
'200':
description: Successful operation
content:
'application/json':
schema:
type: object
properties:
status:
type: string
validated:
type: string
Python Code:
yaml_url= "https://my-host/login.yaml"
yaml_path = r"somepath/file.yaml"
# spec = load_local_spec(yaml_path)
# spec = load_spec_from_url(yaml_url)
response = requests.get(yaml_url)
spec_dict = yaml.load(response.text, Loader=yaml.SafeLoader)
spec = Spec.from_dict(spec_dict, base_uri=yaml_url)
url = 'https://api-stage.northghost.com/partner/login'
r = requests.post(url=url, params={'login': 321, 'password': "some_password"})
request = RequestsOpenAPIRequest(r.request)
print(validate_request(request=request, spec=spec))
print(r.json())
OpenAPI Core Version
openapi_core==0.18.0
OpenAPI Core Integration
Requests
Affected Area(s)
No response
References
No response
Anything else we need to know?
In 0.16 version, where was an iter method, seems to be missing from 0.18, was really handy when parsing and storing errors:
validate_request.iter(self.spec, request_data)
Is it depreciated? Did not see it in the docs
Would you like to implement a fix?
No
Metadata
Metadata
Assignees
Labels
kind/bugIndicates an issueIndicates an issue