Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all attributes which are defined in the openapi files attributes of all models #37

Open
eikes opened this issue Nov 18, 2021 · 2 comments

Comments

@eikes
Copy link
Collaborator

eikes commented Nov 18, 2021

I noticed, that there are many attributes defined in the openapi specification file which are not accessible through the ruby models. As a user of this gem I would like to be able to access all attributes from the API response though.

The match_open_api_definition matcher can be used to show the difference like this:

RSpec::Matchers.define :match_open_api_definition do |scope, model, options = {}|
  # [...]
  match do |actual_model|
    return false if model_node.nil?
    model_attributes = defined_attributes(actual_model)
    (model_attributes - specified_attributes | specified_attributes - model_attributes).empty?
  end

  failure_message do |actual_model|
    if model_node.nil?
      <<~MESSAGE
        Specification not found for #{actual_model}. I was looking for: #{schema_path}. Available specifications:
        #{schemas.keys}
      MESSAGE
    else
      <<~MESSAGE
        expected that the model #{actual_model} would only define attributes defined in the open_api definition, but there are attributes in the model that are not in the specification.
        The attributes which are used in the model but which are not in the specification are:
        #{(defined_attributes(actual_model) - specified_attributes).sort}
        The attributes which are not used in the model but which are in the specification are:
        #{(specified_attributes - defined_attributes(actual_model)).sort}
        The attributes defined in the model are:
        #{defined_attributes(actual_model).sort}
        The attributes defined in the specification are:
        #{specified_attributes.sort}
      MESSAGE
    end
  end
end
@A5308Y
Copy link
Collaborator

A5308Y commented Nov 19, 2021

Yes. This is an ongoing issue. Completeness was not a priority yet and we decided against generating the client from the specs.

Do you have a use-case for all models and all attributes, or are there specific models that are important to you currently @eikes?

@A5308Y
Copy link
Collaborator

A5308Y commented Nov 22, 2021

We had a short discussion in slack and I think we can reduce the scope of the issue to "support all GET-endpoints defined in https://man.pages.ioki.com/api_docs/refs/master/platform-api.html", because the the feature is a provider-dashboard.

Do you think we need the driver and passenger APIs? Do we need more than GET for the dashboard? @ans-ioki @eikes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants