I am trying to generate server and client for go-swagger. (this is my first time using swagger).
And I have these packages:
in my echo $GOPATH => /Users/argentum/dev/go. but when I run swagger generate server -A auth-service -f ./swagger.yml in /Users/argentum/dev/go/swagger-demo .
I get this:
Generation completed!
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/tylerb/graceful
* github.com/jessevdk/go-flags
* golang.org/x/net/context
But I have these packages, I checked in $GOPATH/github.com/<package-names>
Installed swagger with go get -u github.com/go-swagger/go-swagger/cmd/swagger when I do swagger version it shows dev
Create a project diretory under $GOPATH.
make a swagger.yml
onsumes:
- application/json
info:
description: Issues and validates access and refresh tokens and otp for two factor
authentication
title: Authentication service
version: 1.0.0
produces:
- application/json
schemes:
- https
- http
swagger: "2.0"
securityDefinitions:
key:
type: apiKey
in: header
name: authorization
paths:
/v1/customers/login:
delete:
tags: ["customer login"]
responses:
'200':
description: ok
'401':
description: unauthorized
````
## Environment
swagger version: dev
go version: 1.7.4 darwin/amd64
OS: OSX SIERRA
Also it would be cool if you could say, how to do a DELETE/POST request which has headers:
Authorizartion: Bearer
X-Platform: Webapp
```
I know how to do the body.
The message you see actually means everything is OK, it only prints that as a reminder and a tip for when compilation doesn't work.
For bearer auth you want:
securityDefinitions:
auth_token:
type: oauth2
authorizationUrl: http://dummyauth.io
tokenUrl: http://dummytoken.io
flow: accessCode
scopes:
all: all
security:
- auth_token:
- all
oh ok .. :D cool
@casualjim um, where did you get those securityDefinitions values. as in in the documentation or in the examples/authentication its not there, please guide me a bit into figuring out where can I refer to for future problems that are already solved :)
@argentum47, you can find all of that information in the official Swagger 2.0 / OpenAPI 2.0 documentation. For example your question is answered here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-definitions-object
Most helpful comment
The message you see actually means everything is OK, it only prints that as a reminder and a tip for when compilation doesn't work.
For bearer auth you want: