Wednesday, 3 February 2016

Ignoring parameters in Swashbuckle

I’m working with a WebApi that is passed the HttpRequestMessage class which is always available in the ASP.NET WebApi pipeline. However, when the documentation is exposed in Swashbuckle, I get a textbox that shows up where it expects me to enter a value for this parameter.

The operation is defined as follows…

  public async Task Get(HttpRequestMessage request)

The problem is, when the documentation is emitted I end up with this ugly mess...

image

I set about finding a way to instruct Seashbuckle to ignore this parameter, and finding there isn’t anything in the box I set about writing a filter that would do this for me.

In Swashbuckle you can plug-in operation “filters” that can be used to alter the emitted data – the filter is passed the context of the operation being emitted, and you can monkey around with the data that pops out. All I had to do then was create a filter that would look for this datatype, and remove the corresponding data from the results. I ended up with this…

  public class IgnoreHttpRequestMessageOperationFilter : IOperationFilter
  {
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, 
                      ApiDescription apiDescription)
    {
      apiDescription.ParameterDescriptions
        .Where(desc => desc.ParameterDescriptor.ParameterType 
            == typeof(HttpRequestMessage))
        .ToList()
        .ForEach(param =>
        {
          var toRemove = operation.parameters
            .SingleOrDefault(p => p.name == param.Name);

          if (null != toRemove)
            operation.parameters.Remove(toRemove);
        });
    }
  }

With that class in place, I just needed to plug this in to the swagger config file as follows...

  c.OperationFilter();

And Bob's you're uncle...

image

174 comments:

Unknown said...

Cool! thanks for pointing this out! On stackowerflow they suggest to rewrite controllers not to use request as a parameter, which is not suitable for us.

Brave Technologies said...
This comment has been removed by a blog administrator.
Akshay Bheda said...

I was searching solution for the same problem, Thanks to you :)

ZeroTolerance said...

Good job mate. Exactly what I was looking for

Harry said...

Worked like charm. Thank you.

Tarek Mohamed El-Mallah said...
This comment has been removed by the author.
Tarek Mohamed El-Mallah said...
This comment has been removed by the author.
Prachetan Anubhuti - Pragna Prachetas said...

works like a magic ... thanks a ton

Richard Majece said...

I have a huge amount of applications in my phone so I was scared when I lost it. https://cellspyapps.org/track-phone-number/ helped me to track my phone number and find it)

HomeWorkFor.me said...

Be sure to check out the new persuasive essay topics.

Unknown said...

Blog Commenting: An unmatched and nonpareil post i have ever seen. The content is so appealing that it has created an impulse to avail Assignment Help Singapore services.

Praylin S said...

Remarkable post! That's a lot of information. Thanks for taking your time and effort to share this with us. Keep us updated.
Tally Course in Chennai
Tally Classes in Chennai
JavaScript Training in Chennai
JavaScript Course in Chennai
C C++ Training in Chennai
C Training in Chennai
Tally Course in Anna Nagar
Tally Course in T Nagar

Additri Kapoor said...

Having an assignment due tomorrow and understand you can’t do it yourself? But you’re afraid of delegating your paper to some scam services as well? Why not check https://scamfighter.net/review/unemployedprofessors.com on Scamfighter.net

Elan Progret said...

There are so many types of essays; it can be hard to know where to start. History papers aren’t just limited to history classes. These tasks can be assigned to examine any important historical event or a person. While they’re more common in history classes, you can find this type of assignment in sociology or political science course syllabus, or just get a history essay task for your scholarship.

What is a political essay? A political is just as the name suggests an essay based on politics or a political situation. Completing a political essay is impossible without the proper research to fully understand your subject. First, you should study the primary texts, to analyze its contents. You may take advantage of using reliable Internet sources, with available government reports and political parties' news. Scan through reputable newspapers and magazines to compile relevant data for your political essay. Find more political essay at http://writing-a-thesis.net/

jacklinemelda said...

Our non plagiarized custom term papers are reputable and known for offering high quality custom term papers. We normally write academic papers in all disciplines of study including those seeking for write my nursing paper services.

meldaresearch said...

We are prepared to deliver reliable and trusted Custom Research Paper Writing Services in all the outlined levels of study due to the many experts that we have in our company.Our Affordable Writing Services are affordable and cheap as well. Students have very limited cash flows, and their budgets are usually constrained.

Lisa Sequeira said...

Is myassignmenthelp fake? Find out the complete truth behind the services MyAssignmentHelp provides.

meldaresearch said...

We are the best writing company providing Essay Writer Servicesof the highest quality. We guarantee our customers of nothing but the highest quality document. Our Custom Term Paper Writing Services are well referenced, formatted and edited to ensure that the article is rid of unnecessary details.

Alvin Steve said...

A nice post shared.
tree trimmers loxahatchee

Clark said...

Nice post.
tile resurfacing minneapolis

Alvin Steve said...

Amaizng.
emergency restoration services fort lauderdale

Clark said...

Great post.
bathroom remodelers clearfield ut

Clark said...

Nice post.
bathroom remodeling clearfield county

Alvin Steve said...

A nice post shared.
concrete driveway contractors fort pierce

Alvin Steve said...

I really appreciate such a post.
kitchen remodel contractor ogden ut

Alvin Steve said...

Good thoughts and well wishes to you and your family. Stay strong!


kitchen remodel contractor fort lauderdale fl

Puremelda said...

It is understood that you do not have adequate time to write. Buy Custom College Papers and submit the Pre Written Research Papers. Make a decision to order Term Paper Writing Help today.

Petersons said...

Worked like charm. Thank you.
express hotel lahore

Unknown said...

interesting and attractive post.
free airdrops

Unknown said...

Remarkable post.
finecoin

Unknown said...

great post.
123movies

maya said...

You have a good point here!I totally agree with what you have said!!Thanks.
airdrop crypto

maya said...

Very nice!!! This is really good blog information thanks for sharing.
123 movie

meldaresearch said...

Research Papers Writing Services should strive to ensure that all essays meets the pukka standards of the examining bodies. Consider hiring quality but also Qualified Research Paper Writers which are advantageous in terms of ensuring you get only top-quality grades on your Online Research Paper Writing Service.

meldaresearch said...

Are you a student and searching for Write My Research Paper Online Services? Do you wish to acquire high-quality services from Legitimate Custom Research Paper Services? As Custom Research Writing Services can always bring a headache to scholars.

The Gabay Group said...

תמשיכו בפרסום פוסטים מעניינים כמו זה. תודה.
gabaygroup.com

Cinema furniture said...
This comment has been removed by the author.
Cinema furniture said...
This comment has been removed by the author.
Unknown said...

very great content share.

שערים לבית מאלומיניום

Unknown said...

Very Great Article.
סילברגייט

Sankar said...

I have read your blog its very attractive and impressive. I like it your blog.
Final Year Projects for CSE in Dot Net

.Net Training in Chennai

Final Year Project Centers in Chennai

Dot Net Training in Chennai

Aleena said...

בדיוק מה שחיפשתי. תודה רבה.
טבעת יהלום

Dafmatok Hosting Trays said...

כל מילה. תודה על השיתוף, מחכה לעוד פוסטים בנושא
מגשי אירוח טבעוניים

Cinema furniture said...

פוסט מעניין, משתף עם העוקבים שלי. תודה
פינות אוכל מעוצבות

Amediciercosmetic said...

תודה על השיתוף. מחכה לכתבות חדשות.
טיפולים קוסמטיים

Comfi furniture said...

פוסט נחמד. חייב לשתף עם העוקבים שלי.
שולחן פינת אוכל

Unknown said...

great work.

רמקולים שקועים

Planner Productions said...

תודה על השיתוף. מחכה לכתבות חדשות.
הפקת אירועים לחברות

Babiesmall said...

מעולה. תודה על הכתיבה היצירתית.
מגדל למידה

brokertome said...

מזל שנתקלתי בכתבה הזאת. בדיוק בזמן
ברוקרים

Unknown said...

thank you for sharing.

קידום עסקים באינטרנט

gemcreature said...

Excellent information Providing by your Article. Thanks.
playboy bunny necklace silver

Bloxi said...

סופסוף מישהו שתואם לדעותיי בנושא. תודה.
בלוק תמונה

alasksecurity said...


תמשיכו בפרסום פוסטים מעניינים כמו זה. תודה.
אלסק מערכות אבטחה

Reputation management said...

כתיבה מעולה, אהבתי. אשתף עם העוקבים שלי.
ניהול מוניטין ברשת

Sam said...

The application of GM crops has raised various social issues not only locally but internationally as well. Food choices are very much influenced by a large number of factors, including social and cultural factor. Avail Assignment Help on Modified GM Crops by expert writers based in Australia.

Ravi said...


You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you.
Tally ERP 9 Training
tally classes
Tally Training institute in Chennai
Tally course in Chennai

Ravi said...


This content of information has
helped me a lot. It is very well explained and easy to understand.
seo training classes
seo training course
seo training institute in chennai
seo training institutes
seo courses in chennai
seo institutes in chennai
seo classes in chennai
seo training center in chennai

noor said...


نقل عفش من الرياض الى جدة نقل عفش من الرياض الى مكة

Unknown said...

Wow...! Nice post
global asset management seoul

Sitelinx said...

תודה על השיתוף. מחכה לכתבות חדשות.
מומחה קידום אתרים בגוגל

Unknown said...

כל מילה. תודה על השיתוף, מחכה לעוד פוסטים בנושא.
מיטת מעבר

Unknown said...

מזל שנתקלתי בכתבה הזאת. בדיוק בזמן
גיוס כסף לסטארט אפ

Dogma said...

פוסט נחמד. חייב לשתף עם העוקבים שלי.
חברת פיתוח תוכנה

How To Asset Manage said...

I really enjoyed very much with this article here.
global asset management seoul

Global Asset Management Udemy said...

I appreciate you for this blog.
global asset management

meldaresearch said...

Online logistics management writing services are very difficult to complete and many students are always searching for Logistics Writing Services Online to help them complete their logistics coursework writing services and logistic research paper services.

사설토토 said...

פוסט מעניין, משתף עם העוקבים שלי. תודה.
https://canvi.co.il

Clark said...

great post.
מצלמה לבית

intercom4u said...

Good job
אינטרקום לדלת כניסה

Clark said...

great.
global asset management

Fixadoor said...

Good job
Garage door repair Vaughan

Clark said...

thanks for sharing.
Global asset management Seoul

http://powerbitrainings.in/powerbi-training-institute-in-hyderabad/ said...

Hey Loved the post! Great article and congrats on Reaching the To 50! I will be back to visit often


Stratford Management said...

this info is really helpful for me.
stratford management Tokyo

Petersons said...

Bastion Balance Seoul

Bastion Balance Korea

American Male Wellness said...

Well written Blog
Hormone replacement Las Vegas

Petersons said...

Spot on with this article, I really think this website needs more attention. I'll probably be back to read more, thanks for the info.


Bastion Balance Korea

Garage Door Pros Ontario said...

Great article
garage door repair

a1garagedoors said...

Excellent Blog.
garage door repair

riya said...

Help full post, lots of information
gazetted officer
z or r twice
what is isp
space complexity
ng-focus
unexpected token o in json at position 1
do a barrel roll 20 times
cannot set headers after they are sent to the client
how to hack any instagram account 100% working
blink html google trick

Petersons said...

אני לא מסכים עם כל מה שכתוב, אבל מאמר מעניין מאוד

בניית בריכה ביתית

James said...

This is a nice article you shared great information.
overhead door repair edmonton

invincible01 said...

Amazing Article, Really useful information to all So, I hope you will share more information to be check and share here.


Jupyter Notebook
Jupyter Notebook Online
Jupyter Notebook Install
Automation Anywhere Tutorial
Rpa automation anywhere tutorial pdf
Automation anywhere Tutorial for beginners
Kivy Python
Kivy Tutorial
Kivy for Python
Kivy Installation on Windows

Petersons said...

your site layout is very good


Garage Door Repair Chestermere

Garage Door Pros Ontario said...

Interesting Blog
garage door repair pittsburgh

euro cars said...

אם כי אני לא מסכים עם כל מה שנכתב, מאמר מעניין
פולקסווגן קראוול

euro cars said...

מעניין מאוד, למרות שלא הכל מדויק לדעתי
כתרי זירקוניה

euro cars said...

שירות מצוין. ממליץ בחום.
כלב קטן

James said...

informative content
garage door repair etobicoke on

James said...

Useful info shared.
broken torsion spring repair ottawa

James said...

Valuable knowledge
Garage Door Track Adjustment

James said...

Excellent info
garage door repair St Albert

Petersons said...

You have got some great posts in your blog. Keep up with the good work.


pittsburgh garage door repair

James said...

keep it up
fixitmag.com

Petersons said...

You have got some great posts in your blog. Keep up with the good work.


appliance repair etobicoke

James said...

Thanks for posting useful information.
Kald Gart Garage Door Repair

Petersons said...

Good information and great post. I like the website, and am sure to keep returning.


garage door repair oakridge

Micky said...

I really appreciate such a post.
เว็บพนัน UFABET

Micky said...

แทงบอล

Micky said...

Amazing and attractive content
แทงบอลออนไลน์

Petersons said...

I wanted to thank you for this great read. Your blog is one of the finest blog . Thanks for posting this informative article.


Garage Door Repair Doctors

Micky said...

ความหมายศิลปะ

Petersons said...

Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?


Los Angeles Garage Door Repair

Morocco travel said...

Are you a traveller and would like to visit Morocco? Then, your trip is sure to be hitch-free when you travel through a reliable Marrakech day excursion .. marrakech to ouzod day trip
Variety of best things to do in Morocco 5 days desert trips from marrakech . travel morocco Rel morocco travel from spain.. morocco with a. marrakech to ouarzazate day trip
Variety of best things to do and see is adverse when you have a trip to Morocco, with a Agency in

Petersons said...

Great blog, keeping me from working. All the Best


garage door repair east houston tx

Petersons said...

מרתק כמה שלא הבנתי כלום עד שקראתי את המאמר הנפלא הזה


נכס מסחרי מניב למכירה

Petersons said...

חייב להחמיא על הכתיבה. מאמר מצוין.

אינטרקום סקיוריטי

Petersons said...

Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?


silvergaragedoors.ca

Petersons said...

Great blog, keeping me from working. All the Best


garage door repair northwest edmonton

Petersons said...

Valuable information! Looking forward to seeing your notes posted.


Garage Door Installation Pittsburgh

Petersons said...

I wanted to thank you for this great blog! I really enjoying every little bit of it and I have you bookmarked to check out new stuff you post.


garage door repair Calgary

Petersons said...

There are certainly a lot of details like that to take into consideration.


garage door repair company

bbc bangla News said...

Whatsapp Number Call us Now! 01537587949
please visit us: Seo service
sex video: phone home buttons repair Canton
pone video usa: Mobile Phone Repair
pone video usa: Courier Companies In USA

Petersons said...

This discussion unexpectedly takes my attention to join inside. Well, after I read all of them, it gives me new idea for my blog. thanks


garage door repair articles

Petersons said...

I am really very agree with your qualities it is very helpful for look like home. Thanks so much for info and keep it up.


garage door repair Cambridge

Unknown said...

Nicely presented information in this post, I prefer to read this kind of stuff. The quality of content is fine and the conclusion is good. Thanks for the post.


garage door repair 

Petersons said...

חייב להחמיא על הכתיבה. מאמר מצוין.

לבנדר שירותי ניקיון

Micky john said...

Very informative content
News For Finance Magazine

David Smith said...

You have a great blog - I would think your readership is very high?

אטרקציות לבת מצווה

Jack Harry said...

This amazing post impressed me
financial news magazine

Unknown said...

מאמר מצוין נהניתי מכל רגע של קריאה

אטרקציות לבר מצווה 

Jack Harry said...

Nice service there are just few who are providing this service great job.
duct cleaning pittsburgh

Unknown said...

You have a very good site, well constructed and very interesting i have bookmarked you, hopefully you keep posting new stuff, many thanks

air duct cleaning pittsburgh 

David Smith said...

This discussion unexpectedly takes my attention to join inside. Well, after I read all of them, it gives me new idea for my blog. thanks

Garage Door Doctor

Jack Harry said...

Nice content
pittoverheadgaragedoorrepair.com

Micky john said...

This amazing post impressed me

garage door repair burlington

Micky john said...

This amazing post impressed me
cleveland plumbing repair

Micky john said...

Thank you for sharing such a good and useful information.
essay writing service reddit

Micky john said...

I was exactly searching for. Thanks for such a post and please keep it up.
garage door slams shut

Micky john said...

This is a wonderful article, Given so much info in it, These type of articles keeps the user's interest in the website.
duct cleaning pittsburgh

Micky john said...

מעניין מאוד, למרות שלא הכל מדויק לדעתי. היה אפשר להרחיב קצת יותר פה ושם
פיתוח אפליקציה

TanjiroKhun said...

Nice service there are just few who are providing
this service great job.
jav

Micky john said...

I like this post, And I figure that they have a great time to peruse this post, they might take a decent site to make an information, thanks for sharing it with me.
garage door repair burlington

online reputation said...

This is truly the web service provider I was looking for!
commercial garage door installation dallas

Jimmy said...

Excellent article. The writing style which you have used in this article is very good and it made the article of better quality.
Door replacement

Micky said...

It's always exciting to read articles from other writers and practice something from their websites.
Garage Doors Philly

Herry said...

I like this post, And I figure that they have a great time to peruse this post, they might take a decent site to make an information, thanks for sharing it with me.
screen door replacement

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


commercial garage door repair

Jerry said...

So lucky to come across your excellent blog. Your blog brings me a great deal of fun. Good luck with the site.
austin garage door repair

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


garage door cable repair

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


garage door cable repair

Alvin Steve said...

I was exactly searching for. Thanks for such a post and please keep it up.
b2b website design

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


window replacement

Alvin Steve said...

I was exactly searching for. Thanks for such a post and please keep it up.
predictive financial services

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


garage door spring repair

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


commercial air conditioning repair

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


kitchen remodeling northside

Alvin Steve said...

I was exactly searching for. Thanks for such a post and please keep it up.

dentists in santa barbara

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


garage door spring repair

Alvin Steve said...

This is truly the web service provider I was looking for!

--------------------
[url=https://www.livingyourawesome.com/post/i-feel-like-a-failure]feel like a failure[/url]

Herry said...

I really appreciate this wonderful post that you have provided for us. I assure you this would be beneficial for most people.

how are rsus taxed

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


scam sites

Julli said...

I like this post, And I figure that they have a great time to peruse this post, they might take a decent site to make an information, thanks for sharing it with me.
stratford management scam

Petersons said...

You are a extremely clever person!


reputation management

john said...

NO BLAME. NO SHAME. You have tax issues, and it’s our job to solve them. We’ll develop a strategy you can manage and negotiate with the taxing authorities on your behalf.

strategic tax resolution

Petersons said...

Thanks for the update you have nicely covered this topic. keep it up


Mommy Newborn Baby Care

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


Washing Machine Repair

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


scam warning

Petersons said...

אני לא מסכים עם כל מה שכתוב, אבל מאמר מעניין מאוד

פרגולה אלומיניום בצפון

Petersons said...

אני לא מסכים עם כל מה שכתוב, אבל מאמר מעניין מאוד

רעות מלכין איפור קבוע

Petersons said...

Good topic, this is going to help a lot of people get the whole concept


Roofing service in Columbus

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


unlock car

Petersons said...

אני לא מסכים עם כל מה שכתוב, אבל מאמר מעניין מאוד

רעות מלכין איפור קבוע

Julli said...

It's always exciting to read articles from other writers and practice something from their websites.
Clear Water

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


Rolling Steel Doors

Julli said...

So lucky to come across your excellent blog. Your blog brings me a great deal of fun. Good luck with the site.
Lock Re-Key

Julli said...

Your post has those facts which are not accessible from anywhere else. lock installation

James said...

It's always exciting to read articles from other writers and practice something from their websites. Commercial Locksmith in Vaughan

Petersons said...

Thanks for sharing info. Keep up the good work...We hope you will visit our blog often as we discuss topics of interest to you


car key replacement

Chinkansen said...

PG SLOT โปรโมชั่น 100 จากค่ายเกม pg slot คลิกที่นี่ เมื่อทำการสมัครสมาชิกท่านจะได้รับสิทธิพิเศษมากมาย อาทิ โบนัสฟรี เครดิตฟรีและโปรโปรชั่นสุดพดิเศษที่กล่าวมาข้างต้น เกมสล็อตออนไลน์ตอบโจทย์ใครบ้าง ตอบโจทย์ผู้เล่นที่ต้องการเล่นเกมเพื่อความสนุกและสามารถสร้างรายได้ การเล่นสล็อตเพื่อสร้างรายได้นั้นทำได้ง่ายเพียงแค่ศึกษากติกาการเล่นและเลือกเล่นอย่างเหมาะสมและเรามีโหมดทดลองเล่นเกมฟรีให้ท่านได้ทำการทดลองก่อนการลงเดิมพัน อีกทั้งระบบรองรับภาษาไทยซึ่ทำให้เล่นเกมได้ง่ายขึ้น และจะมีเจ้าหน้าหน้าที่ดูแลตลอด 24 ชั่วโมงหากท่านพบเจอปัญหา

Petersons said...

Thanks for sharing info. Keep up the good work...We hope you will visit our blog often as we discuss topics of interest to you


global asset management scam

James said...

A useful post shared. Local Locksmith

Petersons said...

Another helpful post. This is a very nice blog that I will definitively come back to several more times this year!


car locksmith