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

Unused public struct Options #85

Closed
mihirpmehta opened this issue Jun 12, 2018 · 8 comments
Closed

Unused public struct Options #85

mihirpmehta opened this issue Jun 12, 2018 · 8 comments

Comments

@mihirpmehta
Copy link

I have generated the code for my Swagger... In the generated code there are struct Options are generated for header field

that option are nowhere being set in the header anywhere.

to initialise the request those value in option are required which is not being set in header field.

Also i think those value should not be required in creating request

My swagger yml is at http://relatr-dev.westeurope.cloudapp.azure.com:8080/swagger/

You can refer the Signup request in which languageCode: and appVersion are required parameters for creating requesting but those are header parameters

@yonaskolb
Copy link
Owner

Generating header parameters is unfortunately not supported yet. This issue tracks that addition #9

In terms of them not being required, that is controlled in the swagger spec. In your spec they are all marked as required

@mihirpmehta
Copy link
Author

In that case it should not be mandatory to build SignUp Model... Parameter that needs to be added in request should be optional for model or request

@yonaskolb
Copy link
Owner

I wasn't aware that POST bodies could be optional. Is your SignupRequestModel really optional? Wouldn't the request fail without it?

@mihirpmehta
Copy link
Author

No But to build the SignupRequestModel "option" parameter should not be mandatory ... i.e. SignupRequestModel class can have constructor where option argument can be passed as nil.

Thanks

@yonaskolb
Copy link
Owner

Ahh I understand. You can use the convenience init for passing in specific Option values. As they are all optional you don't need to specify them.

AuthSignupPost.Request(body: signupRequestModel)

@yonaskolb
Copy link
Owner

Let me know if that doesn't work or you have any other issues. Closing for now

@mihirpmehta
Copy link
Author

I am using your tool to generate my API only one thing is not clear to me is how to authorise some request

My server uses Bearer Token for authorise user... how should i use authorise protocol ?

Right now i am just putting it in header Authorisation like

APIClient.default.defaultHeaders["Authorization"] = "Bearer \(bearerToken)

But not sure if this is the right way and if it is than what is the use of
public var authorizer: RequestAuthorizer?

@yonaskolb
Copy link
Owner

@mihirpmehta how you're doing it is fine. The RequestAuthorizer is only if you need to authorize asynchronously or only for certain requests.

Mind you RequestAuthorizer is being replaced with RequestBehaviour.validate in #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants