Giter Site home page Giter Site logo

openapi_contracts's People

Contributors

depfu[bot] avatar don-ca avatar dveljacic avatar klausmeyer avatar mkon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openapi_contracts's Issues

Request schema validation

Hi @mkon,

I would really love to see the feature of Request schema validation working similarly to Response schema validation and I see you put it in Future Plans. Do you have any idea when this could be?

I would like to try implementing this myself but first wanted to check with you and see what you think about it, maybe you have some general guidelines or ideas you want me to follow or something like that.

Thank you in advance for your response.
Best regards.

Support for ruby 3.3

Ruby 3.3 has been released in December.

Could openapi_contracts be upgraded/modified to support the new stable version.

Can't parse webhooks in OpenAPI 3.1 spec structured via Redocly

I use Redocly to bundle and split my OpenAPI 3.1.0 spec, which includes webhooks documented under the webhook field.

Based on the first line in the README, and no mention of limited support for OpenAPI 3.1.0, I expected this to work.

Currently supports OpenAPI documentation in the structure as used by Redocly, but should also work for single file schemas.

Instead, when I try to parse my spec (here's the main file), I receive this error:

RuntimeError:
  Unknown file: #<Pathname:webhooks/account.created.yaml>
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser/transformers/pointer.rb:29:in `transform_pointer'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser/transformers/pointer.rb:20:in `transform_refs'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser/transformers/pointer.rb:5:in `call'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:59:in `block in transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:59:in `each'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:59:in `transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `block in transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `each_value'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `block in transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `each_value'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:58:in `transform_objects!'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:51:in `block in file_to_data'
# <internal:kernel>:90:in `tap'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:50:in `file_to_data'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:24:in `block in parse'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:21:in `each'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:21:in `each_with_object'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:21:in `parse'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/parser.rb:8:in `call'
# /usr/local/bundle/gems/openapi_contracts-0.13.0/lib/openapi_contracts/doc.rb:14:in `parse'

TypeError when parsing OAS with `parameters` shared between methods in path

Hi @mkon,

we're getting the following error after updating to 0.7.0:

TypeError:
  no implicit conversion of String into Integer
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/schema.rb:29:in `[]'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/schema.rb:29:in `[]'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/method.rb:5:in `initialize'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/path.rb:6:in `new'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/path.rb:6:in `block in initialize'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/schema.rb:29:in `to_h'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/schema.rb:29:in `to_h'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc/path.rb:5:in `initialize'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:20:in `new'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:20:in `block in initialize'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:19:in `to_h'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:19:in `initialize'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:12:in `new'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/openapi_contracts-0.7.0/lib/openapi_contracts/doc.rb:12:in `parse'
# ./spec/support/helpers/openapi_helper.rb:3:in `oas'
# ./spec/controllers/api/v1/configuration/languages_controller_spec.rb:36:in `block (3 levels) in <top (required)>'
# /Users/kmeyer/.rvm/gems/ruby-3.1.3@service-dbs-configuration/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'

I did a bit of debugging and figured out being related to the case when having a parameters: block shared between the defined methods of a certain path.

Here a way to reproduce it via change in the fixtures:

diff --git spec/fixtures/openapi/paths/message.yaml spec/fixtures/openapi/paths/message.yaml
index 6961280..e122d26 100644
--- spec/fixtures/openapi/paths/message.yaml
+++ spec/fixtures/openapi/paths/message.yaml
@@ -1,16 +1,16 @@
+parameters:
+- name: id
+  in: path
+  description: Id of the message.
+  required: true
+  schema:
+    type: string
 get:
   tags:
     - Message
   summary: Get Message
   description: Get Message
   operationId: get_message
-  parameters:
-  - name: id
-    in: path
-    description: Id of the message.
-    required: true
-    schema:
-      type: string
   responses:

The issue seems to be mainly the parameters key not being filtered out here (or in the logic before):

@methods = @schema.to_h do |method, _|

Let me know if I should try to provide a fix or if you want to do it on your own.

Thanks, Klaus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.