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

Multiple fixes & additions #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

jmeissen
Copy link

Hello,

Nice little macro you have here. I've had to use it for a swagger spec, and it worked pretty well. Except I needed some stuff in there as well. So I decided to add these & also fix some of the FIXME comments.

Apply whatever you want from it.

Fixes

  • Pseudo-dynamic request content type instead of the hardcoded application/json-string
  • Deprecated warning for eval-when

The JSON assumption & body response mapping

Drakma has a builtin variable *text-content-types* which says what body content is definitely text. So since drakma automatically maps the response body to characters based on the content type header, I've added a let-binding after the generated URL which overrides the default drakma:*text-content-types* to ensure correct behavior for json decoding which comes after. So leaving the default behavior the same, while the assumed json body is dropped. The generated function now also returns the string/byte-array when the content type header is not json as its mime subtype.

base-path to endpoint

Idk if you noticed this, but the parameters for the generated functions were applied to the base-path, not to the endpoint, which seems erroneous? So I put that fix in a separate commit as well.

In my case at least I got an error, because the endpoints included the path variables, not the basepath...

Additions

default-headers keyword

The keyword allows to add in :additional-headers some default headers. The headers will be overwritten by headers when applicable. I needed to add some custom authentication headers, so I added this one.

Optional export keyword

Setting the keyword to t automatically adds an export statement for the function symbol. Defaults to nil, so it does not mess with the existing behavior. I wanted a separate package with exported function symbols, so I added this.

Thanks in advance for reviewing the PR.

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.

1 participant