Skip to content

Commit c3aef1f

Browse files
authored
Add gitbook for docs
* [ci skip] Add gitbook for docs * fix links and anchors
1 parent 127cccc commit c3aef1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5612
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ dist
5050
.idea
5151
go-swagger.iml
5252

53+
node_modules
54+
_book

book.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"root": "./docs",
3+
"plugins": [ "forkmegithub", "prism", "-highlight", "anchors" ],
4+
"pluginsConfig": {
5+
"forkmegithub": {
6+
"url": "https://github.com/go-swagger/go-swagger",
7+
"color": "green"
8+
}
9+
}
10+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package commands
22

33
func init() {
4-
Version = "0.5.0-147-g75d539e"
4+
Version = "0.5.0-150-g00cb8f5"
55
}
66

docs/CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
goswagger.io

docs/README.md

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Swagger 2.0 [![Build Status](https://ci.vmware.run/api/badges/go-swagger/go-swagger/status.svg)](https://ci.vmware.run/go-swagger/go-swagger) [![Build status](https://ci.appveyor.com/api/projects/status/x377t5o9ennm847o/branch/master?svg=true)](https://ci.appveyor.com/project/casualjim/go-swagger/branch/master) [![Coverage](https://coverage.vmware.run/badges/go-swagger/go-swagger/coverage.svg)](https://coverage.vmware.run/go-swagger/go-swagger) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
2+
3+
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/swagger-api/swagger-spec/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-swagger/go-swagger?status.svg)](http://godoc.org/github.com/go-swagger/go-swagger) [![GitHub version](https://badge.fury.io/gh/go-swagger%2Fgo-swagger.svg)](https://badge.fury.io/gh/go-swagger%2Fgo-swagger) [![Docker Repository on Quay](https://quay.io/repository/goswagger/swagger/status "Docker Repository on Quay")](https://quay.io/repository/goswagger/swagger)
4+
5+
Development of this toolkit is sponsored by VMware:<br>[![VMWare](https://avatars2.githubusercontent.com/u/473334?v=3&s=200)](https://vmware.github.io)
6+
7+
Contains an implementation of Swagger 2.0. It knows how to serialize and deserialize swagger specifications.
8+
9+
Swagger is a simple yet powerful representation of your RESTful API.<br>With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment.
10+
11+
With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. We created Swagger to help fulfill the promise of APIs.
12+
13+
Swagger helps companies like Apigee, Getty Images, Intuit, LivingSocial, McKesson, Microsoft, Morningstar, and PayPal build the best possible services with RESTful APIs. Now in version 2.0, Swagger is more enabling than ever. And it's 100% open source software.
14+
15+
## Migrating
16+
17+
### From 0.5.0 to 0.6.0
18+
19+
You will have to rename some imports:
20+
21+
```
22+
github.com/go-swagger/go-swagger/httpkit/validate to github.com/go-openapi/validate
23+
github.com/go-swagger/go-swagger/httpkit to github.com/go-openapi/runtime
24+
github.com/naoina/denco to github.com/go-openapi/runtime/middleware/denco
25+
github.com/go-swagger/go-swagger to github.com/go-openapi
26+
```
27+
28+
## Docs
29+
30+
<https://goswagger.io>
31+
32+
### Binary distribution
33+
34+
go-swagger is distributed as binaries that are built of signed tags. It is published as github release, rpm, deb and docker image.
35+
36+
#### Docker image
37+
38+
```shell
39+
docker pull quay.io/goswagger/swagger
40+
41+
alias swagger="docker run --rm -it -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger"
42+
swagger version
43+
```
44+
45+
#### Homebrew/Linuxbrew
46+
47+
```shell
48+
brew tap go-swagger/go-swagger
49+
brew install go-swagger
50+
```
51+
52+
#### Static binary
53+
54+
You can download a binary for your platform from github:
55+
56+
<https://github.com/go-swagger/go-swagger/releases/latest>
57+
58+
```shell
59+
latestv=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | jq -r .tag_name)
60+
curl -o /usr/local/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/$latestv/swagger_$(echo `uname`|tr '[:upper:]' '[:lower:]')_amd64
61+
chmod +x /usr/local/bin/swagger
62+
```
63+
64+
#### Debian packages [ ![Download](https://api.bintray.com/packages/go-swagger/goswagger-debian/swagger/images/download.svg) ](https://bintray.com/go-swagger/goswagger-debian/swagger/_latestVersion)
65+
66+
This repo will work for any debian, the only file it contains gets copied to /usr/bin
67+
68+
```shell
69+
echo "deb https://dl.bintray.com/go-swagger/goswagger-debian ubuntu main" | sudo tee -a /etc/apt/sources.list
70+
```
71+
72+
#### RPM packages [ ![Download](https://api.bintray.com/packages/go-swagger/goswagger-rpm/swagger/images/download.svg) ](https://bintray.com/go-swagger/goswagger-rpm/swagger/_latestVersion)
73+
74+
This repo should work on any distro that wants rpm packages, the only file it contains gets copied to /usr/bin/
75+
76+
```shell
77+
wget https://bintray.com/go-swagger/goswagger-rpm/rpm -O bintray-go-swagger-goswagger-rpm.repo
78+
```
79+
80+
### From source
81+
82+
Install or update from source:
83+
84+
```
85+
go get -u github.com/go-swagger/go-swagger/cmd/swagger
86+
```
87+
88+
The implementation also provides a number of command line tools to help working with swagger.
89+
90+
Currently there is a [spec validator tool](http://goswagger.io/usage/validate/):
91+
92+
```
93+
swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json
94+
```
95+
96+
To generate a server for a swagger spec document:
97+
98+
```
99+
swagger generate server [-f ./swagger.json] -A [application-name [--principal [principal-name]]
100+
```
101+
102+
To generate a [client for a swagger spec](http://goswagger.io/generate/client/) document:
103+
104+
```
105+
swagger generate client [-f ./swagger.json] -A [application-name [--principal [principal-name]]
106+
```
107+
108+
To generate a [swagger spec document for a go application](http://goswagger.io/generate/spec/):
109+
110+
```
111+
swagger generate spec -o ./swagger.json
112+
```
113+
114+
## Licensing
115+
116+
The toolkit itself is licensed as Apache Software License 2.0. Just like swagger, this does not cover code generated by the toolkit. That code is entirely yours to license however you see fit.
117+
118+
## What's inside?
119+
120+
For a V1 I want to have this feature set completed:
121+
122+
- [x] Documentation site
123+
- [x] Play nice with golint, go vet etc.
124+
- [x] An object model that serializes to swagger yaml or json
125+
- [x] A tool to work with swagger:
126+
127+
- [x] validate a swagger spec document:
128+
- [x] validate against jsonschema
129+
- [ ] validate extra rules outlined [here](https://github.com/apigee-127/sway/blob/master/docs/versions/2.0.md#semantic-validation)
130+
131+
- [x] definition can't declare a property that's already defined by one of its ancestors (Error)
132+
- [x] definition's ancestor can't be a descendant of the same model (Error)
133+
- [x] each api path should be non-verbatim (account for path param names) unique per method (Error)
134+
- [ ] each security reference should contain only unique scopes (Warning)
135+
- [x] each path parameter should correspond to a parameter placeholder and vice versa (Error)
136+
- [x] path parameter declarations do not allow empty names _(`/path/{}` is not valid)_ (Error)
137+
- [x] each definition property listed in the required array must be defined in the properties of the model (Error)
138+
- [x] each parameter should have a unique `name` and `in` combination (Error)
139+
- [x] each operation should have at most 1 parameter of type body (Error)
140+
- [x] each operation cannot have both a body parameter and a formData parameter (Error)
141+
- [x] each operation must have an unique `operationId` (Error)
142+
- [x] each reference must point to a valid object (Error)
143+
- [x] each referencable definition must have references (Warning)
144+
- [x] every default value that is specified must validate against the schema for that property (Error)
145+
- [x] every example that is specified must validate against the schema for that property (Error)
146+
- [x] items property is required for all schemas/definitions of type `array` (Error)
147+
148+
- [x] serve swagger UI for any swagger spec file
149+
- [x] code generation
150+
- [x] generate api based on swagger spec
151+
- [x] generate go client from a swagger spec
152+
- [x] spec generation
153+
- [x] generate spec document based on the code
154+
155+
- [x] generate meta data (top level swagger properties) from package docs
156+
- [x] generate definition entries for models
157+
- [x] support composed structs out of several embeds
158+
- [x] support allOf for composed structs
159+
- [x] generate path entries for routes
160+
- [x] generate responses from structs
161+
- [x] support composed structs out of several embeds
162+
- [x] generate parameters from structs
163+
- [x] support composed structs out of several embeds
164+
165+
- [x] Middlewares:
166+
167+
- [x] serve spec
168+
- [x] routing
169+
- [x] validation
170+
- [x] additional validation through an interface
171+
- [x] authorization
172+
173+
- [x] basic auth
174+
- [x] api key auth
175+
- [x] oauth2 bearer auth
176+
177+
- [x] swagger docs UI
178+
179+
- [x] Typed JSON Schema implementation
180+
181+
- [x] JSON Pointer that knows about structs
182+
- [x] JSON Reference that knows about structs
183+
- [x] Passes current json schema test suite
184+
185+
- [x] extended string formats
186+
187+
- [x] uuid, uuid3, uuid4, uuid5
188+
- [x] email
189+
- [x] uri (absolute)
190+
- [x] hostname
191+
- [x] ipv4
192+
- [x] ipv6
193+
- [x] mac
194+
- [x] credit card
195+
- [x] isbn, isbn10, isbn13
196+
- [x] social security number
197+
- [x] hexcolor
198+
- [x] rgbcolor
199+
- [x] date
200+
- [x] date-time
201+
- [x] duration
202+
- [x] password
203+
- [x] custom string formats

docs/SUMMARY.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Summary
2+
3+
- [Introduction](README.md)
4+
- Tutorials
5+
6+
- [Simple Server](tutorial/todo-list.md)
7+
- [Middleware](use/middleware.md)
8+
9+
- [Validate](usage/validate.md)
10+
11+
- Generate
12+
13+
- [API Client](generate/client.md)
14+
- [API Server](generate/server.md)
15+
- [Usage](use/server.md)
16+
- [Model generation rules](use/schemas.md)
17+
- [Custom templates](generate/templates.md)
18+
- [swagger.json](generate/spec.md)
19+
- [swagger:meta](generate/spec/meta.md)
20+
- [swagger:route](generate/spec/route.md)
21+
- [swagger:params](generate/spec/params.md)
22+
- [swagger:response](generate/spec/response.md)
23+
- [swagger:model](generate/spec/model.md)
24+
- [swagger:allOf](generate/spec/allOf.md)
25+
- [swagger:strfmt](generate/spec/strfmt.md)
26+
- [swagger:discriminated](generate/spec/discriminated.md)
27+
28+
29+
- Runtime
30+
31+
- [Dynamic Server](use/server.md)

docs/about.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
+++
2+
date = "2015-10-21T21:54:47-07:00"
3+
title = "What is go-swagger"
4+
series = "home"
5+
weight = 9
6+
+++
7+
8+
There are 2 axis along which your API and its documentation tend to evolve. This toolkit aims to support you along all
9+
axis and remove the repetitive nature of writing what is essentially boilerplate code for faster iteration times.
10+
11+
<!--more-->
12+
13+
The first one is an artifact of that first meeting where you hash out what your service will do. Hopefully you've come
14+
up with some document that services as a kind of contract for what the affected people/teams will need to do.
15+
At this stage you want to be able to generate a server, perhaps a client to talk to that server.
16+
It's not inconceivable you want to have your front-end team use mock data for that server and that the backend team
17+
wants to be left in peace while they work on their part of the application.
18+
19+
This is the **design first** approach for swagger.
20+
21+
Now we're moving on to the second iteration of the project and at this stage, there might be a design meeting for the
22+
new features, or they might just be refinements of the previous API's. When no changes are required to the contract,
23+
all is great because people can keep doing what they were doing and everybody is happy.
24+
However it might be that there was a change that is required for the front-end, they need a boolean added to some model
25+
because they want to display an-accepted-terms-and-conditions-checkbox.
26+
The backend can decide to add this to the code, provide the necessary annotation and regenerate the swagger
27+
specification document.
28+
29+
This is the **code first** approach for swagger.
30+
31+
This toolkit aims to support both these modes, remove the repetitive nature of writing what is essentially boilerplate
32+
code. In doing so it tries to stay as close as possible to the go stdlib interfaces, it tries to have no opinions
33+
besides the fact that documentation is important. And it tries to integrate well with the rest of the go ecosystem as
34+
well as the swagger ecosystem.
35+
36+
A series of contrib projects will add higher level optional functionality so that you can use the generated code with
37+
confidence whether your application is your personal blog or is the next AWS.

docs/favicon-16x16.png

645 Bytes
Loading

docs/favicon-32x32.png

1.62 KB
Loading

docs/favicon.ico

5.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)