Skip to content

Registering multiple APIs for testing #352

@EdwinRozario

Description

@EdwinRozario

Hi Team

I was able to test multiple api docs by registering the docs in the before block of each Rspec request test.

RSpec.shared_context "API registration" do
  api_doc = metadata[:api]

  before do
    OpenapiFirst::Test.register(Rails.root.join("docs", "api", "#{api_doc}.yaml"))
  end
end

But this means the context has to be included in every test and metadats set for every test file. Later i found that i could register multiple docs by

OpenapiFirst::Test.register( Rails.root.join("docs/api/v1.yaml"), as: :v1)
OpenapiFirst::Test.register(Rails.root.join("docs/api/v2.yaml"), as: :v2)

and added RSpec.describe "V1 Endpoint", openapi: :v1 do to the test.

But i am getting OpenapiFirst::Test::NotRegisteredError: when doing the above. Was this not designed to do this? Do you have a suggestion to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions