diff --git a/GNUmakefile b/GNUmakefile index 39c07cf..c101001 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -11,4 +11,4 @@ patch: wget -q --output-document - https://api.bitbucket.org/swagger.json | "$$(go env GOPATH)/bin/json-patch" -p api/swagger.json-patch > api/swagger.output.json generate: patch - swagger-codegen generate -i api/swagger.output.json -l go -c swagger.conf --additional-properties packageName=bitbucket + swagger-codegen generate -i api/swagger.output.json -l go -c swagger.conf --additional-properties packageName=bitbucket --template-dir swagger-template diff --git a/model_pipelines_config.go b/model_pipelines_config.go index dabbc23..d11b9fc 100644 --- a/model_pipelines_config.go +++ b/model_pipelines_config.go @@ -10,8 +10,8 @@ package bitbucket type PipelinesConfig struct { - Type_ string `json:"type"` // Whether Pipelines is enabled for the repository. - Enabled bool `json:"enabled,omitempty"` + Enabled *bool `json:"enabled,omitempty"` Repository *Repository `json:"repository,omitempty"` + Type_ string `json:"type"` } diff --git a/swagger-template/model.mustache b/swagger-template/model.mustache new file mode 100644 index 0000000..e24ab5b --- /dev/null +++ b/swagger-template/model.mustache @@ -0,0 +1,43 @@ +{{>partial_header}} +package {{packageName}} +{{#models}} +{{#imports}} +{{#@first}} +import ( +{{/@first}} + "{{import}}" +{{#@last}} +) +{{/@last}} +{{/imports}} +{{#model}}{{#isEnum}}{{#description}}// {{{classname}}} : {{{description}}}{{/description}} +type {{{classname}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/format}} + +// List of {{{name}}} +const ( + {{#allowableValues}} + {{#enumVars}} + {{^@first}} + {{/@first}} + {{name}}_{{{classname}}} {{{classname}}} = "{{{value}}}" + {{/enumVars}} + {{/allowableValues}} +){{/isEnum}}{{^isEnum}}{{#description}} +// {{{description}}}{{/description}} +type {{classname}} struct { +{{#isComposedModel}} + {{#interfaceModels}} + {{classname}} + {{/interfaceModels}} +{{/isComposedModel}} +{{^isComposedModel}} +{{#vars}} +{{^@first}} +{{/@first}} +{{#description}} + // {{{description}}} +{{/description}} + {{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{#isBoolean}}*{{/isBoolean}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}"{{/withXml}}` +{{/vars}} +{{/isComposedModel}} +}{{/isEnum}}{{/model}}{{/models}} \ No newline at end of file