Comments (20)
Can you check if this would solve your problem?
https://gist.github.com/abelsilva/786daf059ce32246865f5ef9ce19bcfe
putting translations
in the UriTemplate of the methods
from swaggerwcf.
That should work.
Only i have multiple endpoints in multiple Svc files.
I did plan to separate the different endpoints and have each endpoint in a different class.
Is it hard to make the empty uri path for swagger to mean post on parent.
Because that is also how iis handles the uri paths.
Your solution does bring that in line but I had hoped to use a different svc file for every endpoint.
Maybe i can cut u[p the words to mkae it happen :)
like trans to delegate to TRanslations.Svc and then havel "lations" in the method path.
I do wonder if iis works with that.
from swaggerwcf.
nope does not work.
i do need a slash in between trans and lations now.
get /gw/trans/lations
from swaggerwcf.
One other issue is that although i have a nullable field and put required=false in the Swagger parameter attribute it still shows the parameter to be required.
from swaggerwcf.
Would it work if you changed like this?
on Global.asax
:
new ServiceRoute("gw", [...]
to
new ServiceRoute("gw/trans",
and on Service:
[SwaggerWcf("/gw")]
to
[SwaggerWcf("/gw/trans")]
and also the methods
UriTemplate = "/translations"
to
UriTemplate = "/lations",
from swaggerwcf.
I'll check what implication it might have to remove the method name when UriTemplate is empty
It makes sense to not have the method name
from swaggerwcf.
I'll also check that issue with required
thanks
from swaggerwcf.
about the required
issue, can you show me the function signature?
If I use
public Book SpecialFunc(string id, Book[] books)
I get books required
If I use
public Book SpecialFunc(string id, Book[] books = null)
books are not required
from swaggerwcf.
Hi abelsilva,
Here it goes.
This is in the interface:
[SwaggerWcfPath("By culture and page", "Retrieves a translation by culture and page")]
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/cult/{culture}/page/{page}?reftime={reftime}"
)]
TranslationSet GetCultPage(
[SwaggerWcfParameter(true,"The culture")]string culture,
[SwaggerWcfParameter(true, "The page")]string page,
[SwaggerWcfParameter(false, "The last time we updated the translations")]long reftime);
This is implementation (svc.cs) :
[SwaggerWcf("/gw/translations")]
public class TranslationService:ITranslationService
[SwaggerWcfTag("translations")]
public TranslationSet GetCultPage(
[SwaggerWcfParameter(true, "The culture")]string culture,
[SwaggerWcfParameter(true, "The page")]string page,
[SwaggerWcfParameter(false, "The last time we updated the translations")]long reftime)
{
............
}
i know that long is not nullable so that it would be strange for optional field.
But it seems to work and when i call without query parameters it just gets 0 as reftime.
this is the base path:
/gw/translations/cult/{culture}/page/{page}
And then in swagger output page I see all 3 fields
with all 3 having required in the value column.
from swaggerwcf.
oh yeah,
And nullable long is not allowed as query parameter, but i do not have a problem with using a string value.
If i say string and use =null then it will make it an optional parameter?
from swaggerwcf.
if i change it to:
[SwaggerWcfTag("translations")]
public TranslationSet GetCultPage(
[SwaggerWcfParameter(true, "The culture")]string culture,
[SwaggerWcfParameter(true, "The page")]string page,
[SwaggerWcfParameter(false, "The last time we updated the translations")]string reftime=null)
I still see required in the fields of swagger.
from swaggerwcf.
ok, I was checking this issue with body parameters
now I see the issue you have, it makes sense, it's a bug, I'll check it
thanks
from swaggerwcf.
If I have
[SwaggerWcfPath("By culture and page", "Retrieves a translation by culture and page")]
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/cult/{culture}/page/{page}?reftime={reftime}"
)]
[SwaggerWcfTag("translations")]
public Book GetCultPage(
[SwaggerWcfParameter(true, "The culture")] string culture,
[SwaggerWcfParameter(true, "The page")] string page,
[SwaggerWcfParameter(false, "The last time we updated the translations")] long reftime = 0)
{
WebOperationContext woc = WebOperationContext.Current;
if (woc == null)
return null;
Book book = Store.Books.FirstOrDefault();
if (book != null)
{
woc.OutgoingResponse.StatusCode = HttpStatusCode.OK;
return book;
}
woc.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
return null;
}
I get this in swagger (field not required):
from swaggerwcf.
make sure you are using V 0.1.4
from swaggerwcf.
if I change the function to
public Book GetCultPage(
[SwaggerWcfParameter(true, "The culture")] string culture,
[SwaggerWcfParameter(true, "The page")] string page,
[SwaggerWcfParameter(false, "The last time we updated the translations")] string reftime = null)
I also see the reftime as not required
from swaggerwcf.
Hi Abelsilva,
Thank you so much for improving the swagger functionality.
It is great that now it is working with the empty Uri templates.
This makes the interface so much better.
But alas, the fields are still all required in my solution.
I do not understand because I have the exact same parameters
and attibutes of the exact same type
And my swagger still says they are required.
from swaggerwcf.
are you able to paste the full interface and class?
you may omit the contents of the functions
from swaggerwcf.
Dear abelsilva,
Thank you so much for your help and quick response and fix.
I got swagger working now the way i hoped it would.
Thank you so much.
from swaggerwcf.
The required stuff is working alos :)
from swaggerwcf.
thanks!
nice to ear it is working
from swaggerwcf.
Related Issues (20)
- ServiceContract Attribute
- swagger.json file loses details over time HOT 1
- swaggerwcf CPU 100%
- Models NameSpaces.Class but I want just CLass HOT 3
- Request Error while access external models as parameters
- Swaggerwcf doesn't support ServiceContracts with the same methodsname.
- SwaggerWCF issue with routes and yaml HOT 1
- Adding Basic Authentication
- Adding project as a reference - failed to parse JSON/YAML response
- Unclear instuction WebServiceHost / Self Host HOT 3
- returning multiple types
- Generate multiple-files based on different WCF classes or tags HOT 2
- Request URL HOT 1
- URL issue
- In IIS , response body as "no centent" for swaggerWCF HOT 1
- NullReferenceException on GetEnumDescription
- Enum return value not included in definitions
- How to get Swagger json inside my API ?
- Setting an example value when there's an object on GET method
- ProcessProperty() of TypePropertiesProcessor.cs not handling IList type, Solution here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swaggerwcf.