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

Custom headers responses #924

Merged
merged 3 commits into from
May 28, 2024

Conversation

PanosCodes
Copy link
Contributor

@PanosCodes PanosCodes commented Apr 4, 2024

Why

To define custom response headers #706

How

Extend the Apipie::ResponseDescription::ResponseObject with a header method

Example

api :GET, "/pets/:id/with-extra-details", "Get a detailed pet record"
returns code: 200, desc: "Detailed info about the pet" do
  param_group :pet
  property :num_legs, Integer, :desc => "How many legs the pet has"
  header 'Link', String, 'Relative links'
  header 'Current-Page', Integer, 'The current page', required: true
end

def show
  render JSON({ :pet_name => "Barkie", :animal_type => "iguana", :legs => 4 })
end

@PanosCodes PanosCodes force-pushed the custom-headers-responses branch 2 times, most recently from d3b13ed to 20e8c84 Compare April 4, 2024 07:00
@davidwessman
Copy link
Contributor

Is there anyway to use array_of: DescriptionObject that uses the https://github.com/Apipie/apipie-rails?tab=readme-ov-file#embedded-response-descriptions inside the returns block?

@PanosCodes
Copy link
Contributor Author

You can delete this line 😅

raise "cannot specify both block and param_group"
.

I'm not sure why it exists, there are no failing tests if it's removed 🤔

@davidwessman
Copy link
Contributor

You can delete this line 😅

raise "cannot specify both block and param_group"

.
I'm not sure why it exists, there are no failing tests if it's removed 🤔

Hehe, that would be nice!

Copy link
Contributor

@davidwessman davidwessman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! 🚀

@davidwessman
Copy link
Contributor

@mathieujobin Any chance to get this merged?

@mathieujobin
Copy link
Collaborator

Sorry for the delay here

@mathieujobin mathieujobin merged commit 41a6c5a into Apipie:master May 28, 2024
25 checks passed
@davidwessman
Copy link
Contributor

No worries, thank you!

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

Successfully merging this pull request may close these issues.

3 participants