在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:go-swagger开源软件地址:https://gitee.com/mirrors/go-swagger开源软件介绍:Swagger 2.0This package contains a golang implementation of Swagger 2.0 (aka OpenAPI 2.0):it knows how to serialize and deserialize swagger specifications. Swagger is a simple yet powerful representation of your RESTful API.
Features
Our focus with code generation is to produce idiomatic, fast go code, which plays nice with golint, go vet etc. Project status
Most features and building blocks are now in a stable state, with a rich set of CI tests. The go-openapi community actively continues bringing fixes and enhancements to this code base. There is still much room for improvement: contributors and PR's are welcome. You may also get in touch with maintainers on our slack channel. DocumentationFAQQ&A contributed by the community: How is this different from go generator in swagger-codegen?tl;dr The main difference at this moment is that this one actually works... The swagger-codegen project only generates a workable go client and even there it will only support flat models.Further, the go server generated by swagger-codegen is mostly a stub.
What's inside?Here is an outline of available features (see the full list here):
There is more to that...
Installing
Use-casesThe main package of the toolkit, go-swagger/go-swagger, provides command line tools to help working with swagger. The toolkit is highly customizable and allows endless possibilities to work with OpenAPI2.0 specifications. Beside the go-swagger CLI tool and generator, the go-openapi packages provide modular functionality to build custom solutions on top of OpenAPI. The CLI supports shell autocompletion utilities: see here. Serve specification UIMost basic use-case: serve a UI for your spec: swagger serve https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json Validate a specificationTo validate a Swagger specification: swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json Generate an API serverTo generate a server for a swagger spec document: swagger generate server [-f ./swagger.json] -A [application-name [--principal [principal-name]] Generate an API clientTo generate a client for a swagger spec document: swagger generate client [-f ./swagger.json] -A [application-name [--principal [principal-name]] Generate an CLI (Command line tool)To generate a CLI for a swagger spec document: swagger generate cli [-f ./swagger.json] -A [application-name [--principal [principal-name]] Generate a spec from sourceTo generate a swagger spec document for a go application: swagger generate spec -o ./swagger.json Generate a data modelTo generate model structures and validators exposed by the API: swagger generate model --spec={spec} Transform specsThere are several commands allowing you to transform your spec. Resolve and expand $ref's in your spec as inline definitions: swagger expand {spec} Flatten your spec: all external $ref's are imported into the main document and inline schemas reorganized as definitions. swagger flatten {spec} Merge specifications (composition): swagger mixin {spec1} {spec2} Compare specsThe diff command allows you to check backwards compatibility.Type swagger diff {spec1} {spec2} Generate spec markdown specswagger generate markdown -f {spec} --output swagger.mode Try itTry LicensingThe 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. Who is using this project?To name but a few... (feel free to sign in there if you are using this project):
3DSIM Note to users migrating from older releasesMigrating from 0.25 to [master]Changes in the behavior of the generated client regarding defaults in parameters and response headers:
Migrating from 0.24 to 0.25The options for For now, the CLI continues to accept these options. They will be removed in a future version. Generating all definitions is now the default behavior when no other option filters the generation scope.The Migrating from 0.14 to 0.15Generated servers no more import the following package (replaced by go1.8 native functionality): github.com/tylerb/graceful Spec flattening now defaults to minimal changes to models and should be workable for 0.12 users. Users who prefer to stick to 0.13 and 0.14 default flattening mode may now use the Note that the Migrating from 0.12 to 0.13Spec flattening and $ref resolution brought breaking changes in model generation, since all complex things generate their own definitions. Migrating from 0.5.0 to 0.6.0You will have to rename some imports: github.com/go-swagger/go-swagger/httpkit/validate to github.com/go-openapi/validategithub.com/go-swagger/go-swagger/httpkit to github.com/go-openapi/runtimegithub.com/naoina/denco to github.com/go-openapi/runtime/middleware/dencogithub.com/go-swagger/go-swagger to github.com/go-openapi Using 0.5.0Because 0.5.0 and master have diverged significantly, you should checkout the tag 0.5.0 for go-swagger when you use the currently released version. |
2022-08-15
2022-08-17
2022-09-23
2023-10-27
2022-08-18
请发表评论