├── .circleci └── config.yml ├── .gitattributes ├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ └── notify-ci-status.yml ├── .gitignore ├── .npmrc_drone ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── _hardcoded ├── doer.go ├── middleware.go └── tracing.go ├── clientconfig ├── clientconfig.go ├── go.mod ├── go.sum └── tracing.go ├── clients ├── go │ └── gengo.go └── js │ ├── genjs.go │ ├── jsclient_test.go │ ├── models.go │ ├── type_script.go │ └── type_script_test.go ├── docs ├── contributing.md └── pull_request_template.md ├── go.mod ├── go.sum ├── golang.mk ├── hardcoded ├── gen.go └── hardcoded.go ├── logging └── wagclientlogger │ ├── go.mod │ └── wagclientlogger.go ├── main.go ├── main_test.go ├── models └── genmodels.go ├── node.mk ├── npmrc_drone_setup.sh ├── package-lock.json ├── package.json ├── samples ├── Makefile ├── blog.yml ├── db.yml ├── deprecated.yml ├── errors.yml ├── gen-go-basic │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── mock_controller.go │ ├── models │ │ ├── animal.go │ │ ├── author.go │ │ ├── author_array.go │ │ ├── author_set.go │ │ ├── authors_response.go │ │ ├── authors_response_metadata.go │ │ ├── bad_request.go │ │ ├── book.go │ │ ├── dog.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── identifiable.go │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── lowercase.go │ │ ├── omit_empty.go │ │ ├── outputs.go │ │ ├── pet.go │ │ ├── unathorized.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-blog │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grade_file.go │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── outputs.go │ │ ├── section.go │ │ ├── section_type.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-client-only │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── animal.go │ │ ├── author.go │ │ ├── author_array.go │ │ ├── author_set.go │ │ ├── authors_response.go │ │ ├── authors_response_metadata.go │ │ ├── bad_request.go │ │ ├── book.go │ │ ├── dog.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── identifiable.go │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── lowercase.go │ │ ├── omit_empty.go │ │ ├── outputs.go │ │ ├── pet.go │ │ ├── unathorized.go │ │ └── unknown_response.go │ └── servertracing │ │ └── tracing.go ├── gen-go-db-custom-path │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── db │ │ ├── dynamodb │ │ │ ├── deployment.go │ │ │ ├── dynamodb-local.sh │ │ │ ├── dynamodb.go │ │ │ ├── dynamodb_test.go │ │ │ ├── event.go │ │ │ ├── norangethingwithcompositeattributes.go │ │ │ ├── simplething.go │ │ │ ├── teachersharingrule.go │ │ │ ├── thing.go │ │ │ ├── thingallowingbatchwrites.go │ │ │ ├── thingallowingbatchwriteswithcompositeattributes.go │ │ │ ├── thingwithadditionalattributes.go │ │ │ ├── thingwithcompositeattributes.go │ │ │ ├── thingwithcompositeenumattributes.go │ │ │ ├── thingwithdategsi.go │ │ │ ├── thingwithdaterange.go │ │ │ ├── thingwithdaterangekey.go │ │ │ ├── thingwithdatetimecomposite.go │ │ │ ├── thingwithdatetimegsi.go │ │ │ ├── thingwithenumhashkey.go │ │ │ ├── thingwithmatchingkeys.go │ │ │ ├── thingwithmultiusecompositeattribute.go │ │ │ ├── thingwithrequiredcompositepropertiesandkeysonly.go │ │ │ ├── thingwithrequiredfields.go │ │ │ ├── thingwithrequiredfields2.go │ │ │ ├── thingwithtransaction.go │ │ │ ├── thingwithtransactionwithsimplething.go │ │ │ ├── thingwithtransactmultiplegsi.go │ │ │ └── thingwithunderscores.go │ │ ├── interface.go │ │ ├── mock_db.go │ │ └── tests │ │ │ └── tests.go │ ├── models │ │ ├── bad_request.go │ │ ├── branch.go │ │ ├── category.go │ │ ├── deployment.go │ │ ├── event.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── no_range_thing_with_composite_attributes.go │ │ ├── object.go │ │ ├── outputs.go │ │ ├── simple_thing.go │ │ ├── teacher_sharing_rule.go │ │ ├── thing.go │ │ ├── thing_allowing_batch_writes.go │ │ ├── thing_allowing_batch_writes_with_composite_attributes.go │ │ ├── thing_with_additional_attributes.go │ │ ├── thing_with_composite_attributes.go │ │ ├── thing_with_composite_enum_attributes.go │ │ ├── thing_with_date_g_s_i.go │ │ ├── thing_with_date_range.go │ │ ├── thing_with_date_range_key.go │ │ ├── thing_with_date_time_composite.go │ │ ├── thing_with_datetime_g_s_i.go │ │ ├── thing_with_enum_hash_key.go │ │ ├── thing_with_matching_keys.go │ │ ├── thing_with_multi_use_composite_attribute.go │ │ ├── thing_with_required_composite_properties_and_keys_only.go │ │ ├── thing_with_required_fields.go │ │ ├── thing_with_required_fields2.go │ │ ├── thing_with_transact_multiple_g_s_i.go │ │ ├── thing_with_transaction.go │ │ ├── thing_with_transaction_with_simple_thing.go │ │ ├── thing_with_underscores.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-db-only │ ├── db │ │ ├── dynamodb │ │ │ ├── deployment.go │ │ │ ├── dynamodb-local.sh │ │ │ ├── dynamodb.go │ │ │ ├── dynamodb_test.go │ │ │ ├── event.go │ │ │ ├── norangethingwithcompositeattributes.go │ │ │ ├── simplething.go │ │ │ ├── teachersharingrule.go │ │ │ ├── thing.go │ │ │ ├── thingallowingbatchwrites.go │ │ │ ├── thingallowingbatchwriteswithcompositeattributes.go │ │ │ ├── thingwithadditionalattributes.go │ │ │ ├── thingwithcompositeattributes.go │ │ │ ├── thingwithcompositeenumattributes.go │ │ │ ├── thingwithdategsi.go │ │ │ ├── thingwithdaterange.go │ │ │ ├── thingwithdaterangekey.go │ │ │ ├── thingwithdatetimecomposite.go │ │ │ ├── thingwithdatetimegsi.go │ │ │ ├── thingwithenumhashkey.go │ │ │ ├── thingwithmatchingkeys.go │ │ │ ├── thingwithmultiusecompositeattribute.go │ │ │ ├── thingwithrequiredcompositepropertiesandkeysonly.go │ │ │ ├── thingwithrequiredfields.go │ │ │ ├── thingwithrequiredfields2.go │ │ │ ├── thingwithtransaction.go │ │ │ ├── thingwithtransactionwithsimplething.go │ │ │ ├── thingwithtransactmultiplegsi.go │ │ │ └── thingwithunderscores.go │ │ ├── interface.go │ │ ├── mock_db.go │ │ └── tests │ │ │ └── tests.go │ └── models │ │ ├── bad_request.go │ │ ├── branch.go │ │ ├── category.go │ │ ├── deployment.go │ │ ├── event.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── no_range_thing_with_composite_attributes.go │ │ ├── object.go │ │ ├── outputs.go │ │ ├── simple_thing.go │ │ ├── teacher_sharing_rule.go │ │ ├── thing.go │ │ ├── thing_allowing_batch_writes.go │ │ ├── thing_allowing_batch_writes_with_composite_attributes.go │ │ ├── thing_with_additional_attributes.go │ │ ├── thing_with_composite_attributes.go │ │ ├── thing_with_composite_enum_attributes.go │ │ ├── thing_with_date_g_s_i.go │ │ ├── thing_with_date_range.go │ │ ├── thing_with_date_range_key.go │ │ ├── thing_with_date_time_composite.go │ │ ├── thing_with_datetime_g_s_i.go │ │ ├── thing_with_enum_hash_key.go │ │ ├── thing_with_matching_keys.go │ │ ├── thing_with_multi_use_composite_attribute.go │ │ ├── thing_with_required_composite_properties_and_keys_only.go │ │ ├── thing_with_required_fields.go │ │ ├── thing_with_required_fields2.go │ │ ├── thing_with_transact_multiple_g_s_i.go │ │ ├── thing_with_transaction.go │ │ ├── thing_with_transaction_with_simple_thing.go │ │ ├── thing_with_underscores.go │ │ └── unknown_response.go ├── gen-go-db │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── branch.go │ │ ├── category.go │ │ ├── deployment.go │ │ ├── event.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── no_range_thing_with_composite_attributes.go │ │ ├── object.go │ │ ├── outputs.go │ │ ├── simple_thing.go │ │ ├── teacher_sharing_rule.go │ │ ├── thing.go │ │ ├── thing_allowing_batch_writes.go │ │ ├── thing_allowing_batch_writes_with_composite_attributes.go │ │ ├── thing_with_additional_attributes.go │ │ ├── thing_with_composite_attributes.go │ │ ├── thing_with_composite_enum_attributes.go │ │ ├── thing_with_date_g_s_i.go │ │ ├── thing_with_date_range.go │ │ ├── thing_with_date_range_key.go │ │ ├── thing_with_date_time_composite.go │ │ ├── thing_with_datetime_g_s_i.go │ │ ├── thing_with_enum_hash_key.go │ │ ├── thing_with_matching_keys.go │ │ ├── thing_with_multi_use_composite_attribute.go │ │ ├── thing_with_required_composite_properties_and_keys_only.go │ │ ├── thing_with_required_fields.go │ │ ├── thing_with_required_fields2.go │ │ ├── thing_with_transact_multiple_g_s_i.go │ │ ├── thing_with_transaction.go │ │ ├── thing_with_transaction_with_simple_thing.go │ │ ├── thing_with_underscores.go │ │ └── unknown_response.go │ ├── server │ │ ├── db │ │ │ ├── dynamodb │ │ │ │ ├── deployment.go │ │ │ │ ├── dynamodb-local.sh │ │ │ │ ├── dynamodb.go │ │ │ │ ├── dynamodb_test.go │ │ │ │ ├── event.go │ │ │ │ ├── norangethingwithcompositeattributes.go │ │ │ │ ├── simplething.go │ │ │ │ ├── teachersharingrule.go │ │ │ │ ├── thing.go │ │ │ │ ├── thingallowingbatchwrites.go │ │ │ │ ├── thingallowingbatchwriteswithcompositeattributes.go │ │ │ │ ├── thingwithadditionalattributes.go │ │ │ │ ├── thingwithcompositeattributes.go │ │ │ │ ├── thingwithcompositeenumattributes.go │ │ │ │ ├── thingwithdategsi.go │ │ │ │ ├── thingwithdaterange.go │ │ │ │ ├── thingwithdaterangekey.go │ │ │ │ ├── thingwithdatetimecomposite.go │ │ │ │ ├── thingwithdatetimegsi.go │ │ │ │ ├── thingwithenumhashkey.go │ │ │ │ ├── thingwithmatchingkeys.go │ │ │ │ ├── thingwithmultiusecompositeattribute.go │ │ │ │ ├── thingwithrequiredcompositepropertiesandkeysonly.go │ │ │ │ ├── thingwithrequiredfields.go │ │ │ │ ├── thingwithrequiredfields2.go │ │ │ │ ├── thingwithtransaction.go │ │ │ │ ├── thingwithtransactionwithsimplething.go │ │ │ │ ├── thingwithtransactmultiplegsi.go │ │ │ │ └── thingwithunderscores.go │ │ │ ├── interface.go │ │ │ ├── mock_db.go │ │ │ └── tests │ │ │ │ └── tests.go │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-deprecated │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── not_found.go │ │ ├── outputs.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-errors │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── extended_error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── not_found.go │ │ ├── outputs.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-nils │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── nil_fields.go │ │ ├── outputs.go │ │ └── unknown_response.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-go-strings │ ├── client │ │ ├── client.go │ │ ├── doer.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── interface.go │ ├── models │ │ ├── bad_request.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── inputs.go │ │ ├── internal_error.go │ │ ├── nil_fields.go │ │ ├── outputs.go │ │ ├── unknown_response.go │ │ └── where_query_string.go │ ├── server │ │ ├── handlers.go │ │ ├── interface.go │ │ ├── middleware.go │ │ ├── mock_controller.go │ │ └── router.go │ └── servertracing │ │ └── tracing.go ├── gen-js-blog │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-client-only │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-db-custom-path │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-db │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-deprecated │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-errors │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-nils │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js-strings │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── gen-js │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── types.js ├── go.mod ├── go.sum ├── nils.yml ├── strings.yml ├── swagger.yml └── test │ ├── client_test.go │ ├── deprecated_test.go │ ├── errors_test.go │ ├── js │ ├── .babelrc │ ├── circuit_breaker.ts │ ├── initialization.js │ ├── operations.js │ ├── package-lock.json │ ├── package.json │ ├── paging.ts │ ├── retries.js │ └── tsconfig.json │ ├── nils_test.go │ ├── sample_server.go │ └── server_test.go ├── server ├── gendb │ ├── bindata.go │ ├── dynamodb-local.sh.tmpl │ ├── dynamodb.go.tmpl │ ├── dynamodb_test.go.tmpl │ ├── gendb.go │ ├── interface.go.tmpl │ ├── table.go.tmpl │ ├── templatefuncs.go │ └── tests.go.tmpl ├── genserver.go └── router.go ├── swagger ├── file.go ├── formats.go ├── operation.go ├── parameter.go ├── responses.go ├── responses_test.go ├── swagger.go ├── testyml │ ├── 3xxresponse.yml │ ├── badref.yml │ ├── defaults.yml │ ├── missinginternal.yml │ ├── missingmessage.yml │ ├── multisuccess.yml │ ├── override.yml │ └── requiredfield.yml └── types.go ├── templates └── templates.go ├── tracing ├── go.mod ├── go.sum └── tracing.go ├── utils └── utils.go └── validation ├── validation.go └── validation_test.go /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: ~/go/src/github.com/Clever/wag 5 | docker: 6 | - image: cimg/go:1.24 7 | environment: 8 | CIRCLE_ARTIFACTS: /tmp/circleci-artifacts 9 | CIRCLE_TEST_REPORTS: /tmp/circleci-test-results 10 | steps: 11 | - run: 12 | command: |- 13 | sudo apt-get install -y curl 14 | curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh 15 | sudo bash nodesource_setup.sh 16 | sudo apt-get install -y nodejs=18.* 17 | rm nodesource_setup.sh 18 | - run: 19 | command: cd $HOME && git clone --depth 1 -v https://github.com/Clever/ci-scripts.git && cd ci-scripts && git show --oneline -s 20 | name: Clone ci-scripts 21 | - checkout 22 | - setup_remote_docker 23 | - run: 24 | command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS 25 | name: Set up CircleCI artifacts directories 26 | - run: make install_deps 27 | - run: make build 28 | - run: sudo npm install -g jsdoc-to-markdown@^4.0.0 29 | - run: 30 | name: vet 31 | command: go vet -mod=readonly $(go list ./...) 32 | - run: make test 33 | - run: if [ "${CIRCLE_BRANCH}" == "master" ]; then make release && $HOME/ci-scripts/circleci/submodule-github-release $GH_RELEASE_TOKEN clientconfig; fi; 34 | - run: if [ "${CIRCLE_BRANCH}" == "master" ]; then make release && $HOME/ci-scripts/circleci/submodule-github-release $GH_RELEASE_TOKEN logging/wagclientlogger; fi; 35 | - run: if [ "${CIRCLE_BRANCH}" == "master" ]; then make release && $HOME/ci-scripts/circleci/github-release $GH_RELEASE_TOKEN release; fi; 36 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | samples/gen-*/** linguist-generated 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Clever/eng-infra 2 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Clever Coding Standards Agreement 2 | 3 | - [ ] Author and Review Statement, "We agree this code adheres to our [Clever Global Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices?activeCard=a8a444f4-9149-4ec7-a0fd-8ba42519d93e) and other applicable [Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices)" 4 | 5 | ## Clever Coding Standards Agreement 6 | 7 | - [ ] Author and Review Statement, "We agree this code adheres to our [Clever Global Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices?activeCard=a8a444f4-9149-4ec7-a0fd-8ba42519d93e) and other applicable [Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices)" 8 | 9 | ## JIRA 10 | [Link to JIRA](insert url here) 11 | 12 | ## Overview 13 | (insert PR description here) 14 | 15 | ## Testing 16 | (how did you test this) 17 | 18 | ## Rollout 19 | (are there any special rollout considerations? specific steps? risks?) 20 | 21 | ## Rollback 22 | (specific steps? risks?) -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gomod 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "10:00" 8 | timezone: America/Los_Angeles 9 | open-pull-requests-limit: 1 10 | ignore: 11 | - dependency-name: github.com/go-openapi/errors 12 | - dependency-name: github.com/go-openapi/spec 13 | - dependency-name: github.com/go-openapi/strfmt 14 | - dependency-name: "go.opentelemetry.io/*" 15 | -------------------------------------------------------------------------------- /.github/workflows/notify-ci-status.yml: -------------------------------------------------------------------------------- 1 | name: Notify CI status 2 | 3 | on: 4 | check_suite: 5 | types: [completed] 6 | status: 7 | 8 | jobs: 9 | call-workflow: 10 | if: >- 11 | (github.event.branches[0].name == github.event.repository.default_branch && 12 | (github.event.state == 'error' || github.event.state == 'failure')) || 13 | (github.event.check_suite.head_branch == github.event.repository.default_branch && 14 | github.event.check_suite.conclusion != 'success') 15 | uses: Clever/ci-scripts/.github/workflows/reusable-notify-ci-status.yml@master 16 | secrets: 17 | CIRCLE_CI_INTEGRATIONS_URL: ${{ secrets.CIRCLE_CI_INTEGRATIONS_URL }} 18 | CIRCLE_CI_INTEGRATIONS_USERNAME: ${{ secrets.CIRCLE_CI_INTEGRATIONS_USERNAME }} 19 | CIRCLE_CI_INTEGRATIONS_PASSWORD: ${{ secrets.CIRCLE_CI_INTEGRATIONS_PASSWORD }} 20 | SLACK_BOT_TOKEN: ${{ secrets.DAPPLE_BOT_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | impl/impl 27 | 28 | bin/ 29 | 30 | vendor/ 31 | badcode.txt 32 | release/ 33 | 34 | node_modules/ 35 | 36 | /samples/gen-go-db/server/db/dynamodb/shared-local-instance.db 37 | -------------------------------------------------------------------------------- /.npmrc_drone: -------------------------------------------------------------------------------- 1 | ca = null 2 | //registry.npmjs.org/:_authToken=${npm_token} 3 | @clever:registry=https://registry.npmjs.org 4 | always-auth = true 5 | strict-ssl = true 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.1 2 | 3 | # need to mount your $GOPATH/src 4 | VOLUME /gopath/src 5 | ENV GOPATH /gopath 6 | 7 | ENTRYPOINT ["/bin/wag"] 8 | 9 | ADD ./bin/wag /bin/wag 10 | -------------------------------------------------------------------------------- /clientconfig/clientconfig.go: -------------------------------------------------------------------------------- 1 | package clientconfig 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/Clever/kayvee-go/v7/logger" 8 | sdktrace "go.opentelemetry.io/otel/sdk/trace" 9 | ) 10 | 11 | func ClientLogger(wagAppName string) *logger.Logger { 12 | return logger.NewConcreteLogger(fmt.Sprintf("%s-wagclient", wagAppName)) 13 | } 14 | 15 | // WithoutTracing is now Deprecated and so is WithTracing, but both are still provided for backwards compatibility. 16 | // Use Default instead. 17 | func WithoutTracing(wagAppName string) (*logger.Logger, *http.RoundTripper) { 18 | return Default(wagAppName) 19 | } 20 | 21 | // Default returns a logger and a transport to use in client requests. 22 | // It is meant as a convenience function for initiating Wag clients 23 | func Default(wagAppName string) (*logger.Logger, *http.RoundTripper) { 24 | baseTransport := http.DefaultTransport 25 | instrumentedTransport := DefaultInstrumentor(baseTransport, wagAppName) 26 | return ClientLogger(wagAppName), &instrumentedTransport 27 | } 28 | 29 | // WithTracing is now Deprecated and so is WithoutTracing, but both are still provided for backwards compatibility. 30 | // Use Default instad. 31 | func WithTracing(wagAppName string, exporter sdktrace.SpanExporter) (*logger.Logger, *http.RoundTripper) { 32 | return Default(wagAppName) 33 | } 34 | -------------------------------------------------------------------------------- /clientconfig/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/clientconfig/v9 2 | 3 | go 1.24.0 4 | 5 | require ( 6 | github.com/Clever/kayvee-go/v7 v7.10.0 7 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 8 | go.opentelemetry.io/otel v1.35.0 9 | go.opentelemetry.io/otel/sdk v1.35.0 10 | ) 11 | 12 | require ( 13 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20230110184825-edb52117e67a // indirect 14 | github.com/felixge/httpsnoop v1.0.4 // indirect 15 | github.com/go-logr/logr v1.4.2 // indirect 16 | github.com/go-logr/stdr v1.2.2 // indirect 17 | github.com/google/uuid v1.6.0 // indirect 18 | github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect 19 | github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect 20 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect 21 | go.opentelemetry.io/auto/sdk v1.1.0 // indirect 22 | go.opentelemetry.io/otel/metric v1.35.0 // indirect 23 | go.opentelemetry.io/otel/trace v1.35.0 // indirect 24 | golang.org/x/sys v0.30.0 // indirect 25 | gopkg.in/yaml.v2 v2.4.0 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /clientconfig/tracing.go: -------------------------------------------------------------------------------- 1 | package clientconfig 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 8 | "go.opentelemetry.io/otel" 9 | ) 10 | 11 | // DefaultInstrumentor returns the transport to use in client requests. 12 | // It takes in a transport to wrap, e.g. http.DefaultTransport, and the app it will be a client of 13 | func DefaultInstrumentor(baseTransport http.RoundTripper, appName string) http.RoundTripper { 14 | return roundTripperWithTracing{baseTransport: baseTransport, appName: appName} 15 | } 16 | 17 | type roundTripperWithTracing struct { 18 | baseTransport http.RoundTripper 19 | appName string 20 | } 21 | 22 | func (rt roundTripperWithTracing) RoundTrip(r *http.Request) (*http.Response, error) { 23 | return otelhttp.NewTransport( 24 | rt.baseTransport, 25 | otelhttp.WithTracerProvider(otel.GetTracerProvider()), 26 | otelhttp.WithPropagators(otel.GetTextMapPropagator()), 27 | otelhttp.WithSpanNameFormatter(func(method string, r *http.Request) string { 28 | v, ok := r.Context().Value("otelSpanName").(string) 29 | if ok { 30 | return v 31 | } 32 | return fmt.Sprintf("%s-wagclient %s %s", rt.appName, r.Method, r.URL.Path) 33 | }), 34 | ).RoundTrip(r) 35 | } 36 | -------------------------------------------------------------------------------- /clients/js/jsclient_test.go: -------------------------------------------------------------------------------- 1 | package jsclient 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestFillOutPath(t *testing.T) { 10 | testSpecs := []struct { 11 | i string 12 | o string 13 | }{ 14 | {"/url", "/url"}, 15 | {"/url/{param}", `/url/" + params.param + "`}, 16 | {"/url/{Param}", `/url/" + params.Param + "`}, 17 | {"/url/{param}/other/{longParam}", `/url/" + params.param + "/other/" + params.longParam + "`}, 18 | {"/url/{param_1}/other/{param_2}", `/url/" + params.param1 + "/other/" + params.param2 + "`}, 19 | } 20 | for _, spec := range testSpecs { 21 | assert.Equal(t, spec.o, fillOutPath(spec.i)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /clients/js/models.go: -------------------------------------------------------------------------------- 1 | package jsclient 2 | 3 | // PrimitiveTypes is a set of Swagger primitive types 4 | var PrimitiveTypes = map[string]bool{ 5 | "string": true, 6 | "number": true, 7 | "integer": true, 8 | "boolean": true, 9 | "array": true, 10 | "object": true, 11 | } 12 | 13 | // DataType represents a primitive or defined type 14 | type DataType struct { 15 | Name string 16 | Ref *string 17 | } 18 | 19 | // Param represents a function's formal parameter 20 | type Param struct { 21 | Name string 22 | Type DataType 23 | } 24 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ### Development setup 4 | 5 | $ make install_deps 6 | 7 | ### Run tests 8 | 9 | $ make test 10 | 11 | ### Submit a patch 12 | 13 | 1. Create a branch 14 | 1. Run `make test` 15 | 1. Submit a pull request 16 | -------------------------------------------------------------------------------- /docs/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Jira 2 | 3 | (Please add a link to a Jira ticket. If you are external to Clever, we can create this for you.) 4 | 5 | ## Testing 6 | 7 | TODO 8 | 9 | ## Checklist 10 | - [ ] Run `make build` 11 | - [ ] Run `make generate` 12 | - [ ] Update the current version in the `/VERSION` file. First line should be JUST the version e.g. `v10.13.1`. Then a blank line. Then release notes. 13 | -------------------------------------------------------------------------------- /hardcoded/gen.go: -------------------------------------------------------------------------------- 1 | package hardcoded 2 | 3 | //go:generate go-bindata -nometadata -pkg hardcoded -o hardcoded.go ../_hardcoded/ 4 | //go:generate gofmt -w hardcoded.go 5 | -------------------------------------------------------------------------------- /logging/wagclientlogger/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/logging/wagclientlogger 2 | 3 | go 1.24.0 4 | -------------------------------------------------------------------------------- /logging/wagclientlogger/wagclientlogger.go: -------------------------------------------------------------------------------- 1 | package wagclientlogger 2 | 3 | //WagClientLogger provides a minimal interface for a Wag Client Logger 4 | type WagClientLogger interface { 5 | Log(level LogLevel, message string, pairs map[string]interface{}) 6 | } 7 | 8 | //M is a convenience type to avoid having to type out map[string]interface{} everytime. 9 | type M map[string]interface{} 10 | 11 | //LogLevel is an enum of valid log levels. 12 | type LogLevel int 13 | 14 | // Constants used to define different LogLevels supported 15 | const ( 16 | Trace LogLevel = iota 17 | Debug 18 | Info 19 | Warning 20 | Error 21 | Critical 22 | FromEnv 23 | ) 24 | -------------------------------------------------------------------------------- /npmrc_drone_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | 4 | sed -i.bak s/\${npm_token}/$npm_token/ .npmrc_drone 5 | mv .npmrc_drone test/js/.npmrc 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@opentelemetry/core": "^1.24.0", 4 | "hystrixjs": "^0.2.0", 5 | "node": "^18.20.2" 6 | }, 7 | "devDependencies": { 8 | "typescript": "^5.4.5" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /samples/deprecated.yml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | info: 3 | title: swagger-test 4 | description: Testing Swagger Codegen 5 | version: 9.0.0 6 | x-npm-package: swagger-test 7 | basePath: /v1 8 | schemes: 9 | - http 10 | produces: 11 | - application/json 12 | consumes: 13 | - application/json 14 | responses: 15 | BadRequest: 16 | description: "Bad Request" 17 | schema: 18 | $ref: "#/definitions/BadRequest" 19 | InternalError: 20 | description: "Internal Error" 21 | schema: 22 | $ref: "#/definitions/InternalError" 23 | paths: 24 | /health: 25 | get: 26 | operationId: health 27 | parameters: 28 | - name: section 29 | in: query 30 | required: true 31 | type: integer 32 | deprecated: true 33 | responses: 34 | 200: 35 | description: OK response 36 | 404: 37 | description: OK response 38 | schema: 39 | $ref: "#/definitions/NotFound" 40 | 41 | definitions: 42 | BadRequest: 43 | type: object 44 | properties: 45 | message: 46 | type: string 47 | 48 | InternalError: 49 | type: object 50 | properties: 51 | message: 52 | type: string 53 | 54 | NotFound: 55 | type: object 56 | properties: 57 | message: 58 | type: string 59 | -------------------------------------------------------------------------------- /samples/errors.yml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | info: 3 | title: swagger-test 4 | description: Testing Swagger Codegen 5 | version: 9.0.0 6 | x-npm-package: swagger-test 7 | basePath: /v1 8 | schemes: 9 | - http 10 | produces: 11 | - application/json 12 | consumes: 13 | - application/json 14 | responses: 15 | BadRequest: 16 | description: "Bad Request" 17 | schema: 18 | $ref: "#/definitions/BadRequest" 19 | InternalError: 20 | description: "Internal Error" 21 | schema: 22 | $ref: "#/definitions/InternalError" 23 | NotFound: 24 | description: "Not found" 25 | schema: 26 | $ref: "#/definitions/NotFound" 27 | 28 | paths: 29 | /books/{id}: 30 | get: 31 | operationId: getBook 32 | parameters: 33 | - name: id 34 | in: path 35 | required: true 36 | type: integer 37 | maximum: 4000 38 | responses: 39 | 200: 40 | description: OK response 41 | 400: 42 | description: "Extended error" 43 | schema: 44 | $ref: "#/definitions/ExtendedError" 45 | 404: 46 | $ref: "#/responses/NotFound" 47 | 500: 48 | $ref: "#/responses/InternalError" 49 | 50 | definitions: 51 | 52 | NotFound: 53 | type: object 54 | properties: 55 | message: 56 | type: string 57 | 58 | BadRequest: 59 | type: object 60 | properties: 61 | message: 62 | type: string 63 | 64 | InternalError: 65 | type: object 66 | properties: 67 | message: 68 | type: string 69 | code: 70 | type: integer 71 | 72 | ExtendedError: 73 | type: object 74 | properties: 75 | message: 76 | type: string 77 | code: 78 | type: integer 79 | 80 | -------------------------------------------------------------------------------- /samples/gen-go-basic/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-basic/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-basic/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-basic/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/animal.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Animal animal 14 | // 15 | // swagger:model Animal 16 | type Animal struct { 17 | 18 | // age 19 | Age int64 `json:"age,omitempty"` 20 | 21 | // species 22 | Species string `json:"species,omitempty"` 23 | } 24 | 25 | // Validate validates this animal 26 | func (m *Animal) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Animal) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Animal) UnmarshalBinary(b []byte) error { 40 | var res Animal 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/author.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Author author 14 | // 15 | // swagger:model Author 16 | type Author struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | } 24 | 25 | // Validate validates this author 26 | func (m *Author) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Author) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Author) UnmarshalBinary(b []byte) error { 40 | var res Author 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/author_array.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "strconv" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | ) 15 | 16 | // AuthorArray author array 17 | // 18 | // swagger:model AuthorArray 19 | type AuthorArray []*Author 20 | 21 | // Validate validates this author array 22 | func (m AuthorArray) Validate(formats strfmt.Registry) error { 23 | var res []error 24 | 25 | for i := 0; i < len(m); i++ { 26 | if swag.IsZero(m[i]) { // not required 27 | continue 28 | } 29 | 30 | if m[i] != nil { 31 | if err := m[i].Validate(formats); err != nil { 32 | if ve, ok := err.(*errors.Validation); ok { 33 | return ve.ValidateName(strconv.Itoa(i)) 34 | } 35 | return err 36 | } 37 | } 38 | 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/authors_response_metadata.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // AuthorsResponseMetadata authors response metadata 14 | // 15 | // swagger:model AuthorsResponseMetadata 16 | type AuthorsResponseMetadata struct { 17 | 18 | // count 19 | Count int64 `json:"count,omitempty"` 20 | } 21 | 22 | // Validate validates this authors response metadata 23 | func (m *AuthorsResponseMetadata) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *AuthorsResponseMetadata) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *AuthorsResponseMetadata) UnmarshalBinary(b []byte) error { 37 | var res AuthorsResponseMetadata 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Error error 14 | // 15 | // swagger:model Error 16 | type Error struct { 17 | 18 | // code 19 | Code int32 `json:"code,omitempty"` 20 | 21 | // message 22 | Message string `json:"message,omitempty"` 23 | } 24 | 25 | // Validate validates this error 26 | func (m *Error) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Error) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Error) UnmarshalBinary(b []byte) error { 40 | var res Error 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-basic/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/identifiable.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Identifiable identifiable 14 | // 15 | // swagger:model Identifiable 16 | type Identifiable struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | } 21 | 22 | // Validate validates this identifiable 23 | func (m *Identifiable) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *Identifiable) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *Identifiable) UnmarshalBinary(b []byte) error { 37 | var res Identifiable 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/lowercase.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | ) 11 | 12 | // Lowercase lowercase 13 | // 14 | // swagger:model lowercase 15 | type Lowercase string 16 | 17 | // Validate validates this lowercase 18 | func (m Lowercase) Validate(formats strfmt.Registry) error { 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/omit_empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // OmitEmpty omit empty 14 | // 15 | // swagger:model OmitEmpty 16 | type OmitEmpty struct { 17 | 18 | // array field not omitted 19 | ArrayFieldNotOmitted []string `json:"arrayFieldNotOmitted"` 20 | 21 | // array field omitted 22 | ArrayFieldOmitted []string `json:"arrayFieldOmitted,omitempty"` 23 | } 24 | 25 | // Validate validates this omit empty 26 | func (m *OmitEmpty) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *OmitEmpty) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *OmitEmpty) UnmarshalBinary(b []byte) error { 40 | var res OmitEmpty 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o Error) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (o InternalError) Error() string { 14 | return o.Message 15 | } 16 | 17 | func (o Unathorized) Error() string { 18 | return o.Message 19 | } 20 | 21 | func (u UnknownResponse) Error() string { 22 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 23 | } 24 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/unathorized.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Unathorized unathorized 14 | // 15 | // swagger:model Unathorized 16 | type Unathorized struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this unathorized 23 | func (m *Unathorized) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *Unathorized) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *Unathorized) UnmarshalBinary(b []byte) error { 37 | var res Unathorized 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-basic/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-blog/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-blog/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-blog/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-blog/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-blog/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-blog/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-blog/models/v9 10 | 11 | // Client defines the methods available to clients of the blog service. 12 | type Client interface { 13 | 14 | // PostGradeFileForStudent makes a POST request to /students/{student_id}/gradeFile 15 | // Posts the grade file for the specified student 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | PostGradeFileForStudent(ctx context.Context, i *models.PostGradeFileForStudentInput) error 21 | 22 | // GetSectionsForStudent makes a GET request to /students/{student_id}/sections 23 | // Gets the sections for the specified student 24 | // 200: []models.Section 25 | // 400: *models.BadRequest 26 | // 500: *models.InternalError 27 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 28 | GetSectionsForStudent(ctx context.Context, studentID string) ([]models.Section, error) 29 | 30 | // PostSectionsForStudent makes a POST request to /students/{student_id}/sections 31 | // Posts the sections for the specified student 32 | // 200: []models.Section 33 | // 400: *models.BadRequest 34 | // 500: *models.InternalError 35 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 36 | PostSectionsForStudent(ctx context.Context, i *models.PostSectionsForStudentInput) ([]models.Section, error) 37 | } 38 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-blog/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/grade_file.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | import "io" 6 | 7 | // This file was generated by the swagger tool. 8 | // Editing this file might prove futile when you re-run the swagger generate command 9 | 10 | // GradeFile grade file 11 | // 12 | // swagger:model GradeFile 13 | type GradeFile io.ReadCloser 14 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/section.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Section section 14 | // 15 | // swagger:model Section 16 | type Section struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | 24 | // period 25 | Period string `json:"period,omitempty"` 26 | } 27 | 28 | // Validate validates this section 29 | func (m *Section) Validate(formats strfmt.Registry) error { 30 | return nil 31 | } 32 | 33 | // MarshalBinary interface implementation 34 | func (m *Section) MarshalBinary() ([]byte, error) { 35 | if m == nil { 36 | return nil, nil 37 | } 38 | return swag.WriteJSON(m) 39 | } 40 | 41 | // UnmarshalBinary interface implementation 42 | func (m *Section) UnmarshalBinary(b []byte) error { 43 | var res Section 44 | if err := swag.ReadJSON(b, &res); err != nil { 45 | return err 46 | } 47 | *m = res 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /samples/gen-go-blog/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-blog/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-blog/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-blog/models/v9 10 | 11 | // Controller defines the interface for the blog service. 12 | type Controller interface { 13 | 14 | // PostGradeFileForStudent handles POST requests to /students/{student_id}/gradeFile 15 | // Posts the grade file for the specified student 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | PostGradeFileForStudent(ctx context.Context, i *models.PostGradeFileForStudentInput) error 21 | 22 | // GetSectionsForStudent handles GET requests to /students/{student_id}/sections 23 | // Gets the sections for the specified student 24 | // 200: []models.Section 25 | // 400: *models.BadRequest 26 | // 500: *models.InternalError 27 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 28 | GetSectionsForStudent(ctx context.Context, studentID string) ([]models.Section, error) 29 | 30 | // PostSectionsForStudent handles POST requests to /students/{student_id}/sections 31 | // Posts the sections for the specified student 32 | // 200: []models.Section 33 | // 400: *models.BadRequest 34 | // 500: *models.InternalError 35 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 36 | PostSectionsForStudent(ctx context.Context, i *models.PostSectionsForStudentInput) ([]models.Section, error) 37 | } 38 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-client-only/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-client-only/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-client-only/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/animal.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Animal animal 14 | // 15 | // swagger:model Animal 16 | type Animal struct { 17 | 18 | // age 19 | Age int64 `json:"age,omitempty"` 20 | 21 | // species 22 | Species string `json:"species,omitempty"` 23 | } 24 | 25 | // Validate validates this animal 26 | func (m *Animal) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Animal) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Animal) UnmarshalBinary(b []byte) error { 40 | var res Animal 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/author.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Author author 14 | // 15 | // swagger:model Author 16 | type Author struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | } 24 | 25 | // Validate validates this author 26 | func (m *Author) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Author) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Author) UnmarshalBinary(b []byte) error { 40 | var res Author 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/author_array.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "strconv" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/swag" 14 | ) 15 | 16 | // AuthorArray author array 17 | // 18 | // swagger:model AuthorArray 19 | type AuthorArray []*Author 20 | 21 | // Validate validates this author array 22 | func (m AuthorArray) Validate(formats strfmt.Registry) error { 23 | var res []error 24 | 25 | for i := 0; i < len(m); i++ { 26 | if swag.IsZero(m[i]) { // not required 27 | continue 28 | } 29 | 30 | if m[i] != nil { 31 | if err := m[i].Validate(formats); err != nil { 32 | if ve, ok := err.(*errors.Validation); ok { 33 | return ve.ValidateName(strconv.Itoa(i)) 34 | } 35 | return err 36 | } 37 | } 38 | 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/authors_response_metadata.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // AuthorsResponseMetadata authors response metadata 14 | // 15 | // swagger:model AuthorsResponseMetadata 16 | type AuthorsResponseMetadata struct { 17 | 18 | // count 19 | Count int64 `json:"count,omitempty"` 20 | } 21 | 22 | // Validate validates this authors response metadata 23 | func (m *AuthorsResponseMetadata) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *AuthorsResponseMetadata) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *AuthorsResponseMetadata) UnmarshalBinary(b []byte) error { 37 | var res AuthorsResponseMetadata 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Error error 14 | // 15 | // swagger:model Error 16 | type Error struct { 17 | 18 | // code 19 | Code int32 `json:"code,omitempty"` 20 | 21 | // message 22 | Message string `json:"message,omitempty"` 23 | } 24 | 25 | // Validate validates this error 26 | func (m *Error) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Error) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Error) UnmarshalBinary(b []byte) error { 40 | var res Error 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-client-only/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/identifiable.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Identifiable identifiable 14 | // 15 | // swagger:model Identifiable 16 | type Identifiable struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | } 21 | 22 | // Validate validates this identifiable 23 | func (m *Identifiable) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *Identifiable) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *Identifiable) UnmarshalBinary(b []byte) error { 37 | var res Identifiable 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/lowercase.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | ) 11 | 12 | // Lowercase lowercase 13 | // 14 | // swagger:model lowercase 15 | type Lowercase string 16 | 17 | // Validate validates this lowercase 18 | func (m Lowercase) Validate(formats strfmt.Registry) error { 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/omit_empty.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // OmitEmpty omit empty 14 | // 15 | // swagger:model OmitEmpty 16 | type OmitEmpty struct { 17 | 18 | // array field not omitted 19 | ArrayFieldNotOmitted []string `json:"arrayFieldNotOmitted"` 20 | 21 | // array field omitted 22 | ArrayFieldOmitted []string `json:"arrayFieldOmitted,omitempty"` 23 | } 24 | 25 | // Validate validates this omit empty 26 | func (m *OmitEmpty) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *OmitEmpty) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *OmitEmpty) UnmarshalBinary(b []byte) error { 40 | var res OmitEmpty 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o Error) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (o InternalError) Error() string { 14 | return o.Message 15 | } 16 | 17 | func (o Unathorized) Error() string { 18 | return o.Message 19 | } 20 | 21 | func (u UnknownResponse) Error() string { 22 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 23 | } 24 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/unathorized.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Unathorized unathorized 14 | // 15 | // swagger:model Unathorized 16 | type Unathorized struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this unathorized 23 | func (m *Unathorized) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *Unathorized) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *Unathorized) UnmarshalBinary(b []byte) error { 37 | var res Unathorized 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-client-only/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-db-custom-path/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-db-custom-path/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-db-custom-path/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-db-custom-path/models/v9 8 | 9 | // Client defines the methods available to clients of the swagger-test service. 10 | type Client interface { 11 | 12 | // HealthCheck makes a GET request to /health/check 13 | // 14 | // 200: nil 15 | // 400: *models.BadRequest 16 | // 500: *models.InternalError 17 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 18 | HealthCheck(ctx context.Context) error 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/db/dynamodb/dynamodb-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | jar=/tmp/DynamoDBLocal.jar 6 | 7 | # download the dynamo jar if necessary 8 | if [ ! -e "$jar" ] 9 | then 10 | if [ `uname` = "Darwin" ] ; then 11 | # this will prompt for java to be installed if necessary 12 | java -version 13 | else 14 | sudo apt-get update && sudo apt-get install -y default-jre 15 | fi 16 | echo "Downloading dynamodb-local..." 17 | curl -L -k --url https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -o /tmp/dynamodb_local_latest.tar.gz 18 | tar -zxvf /tmp/dynamodb_local_latest.tar.gz -C /tmp/ 19 | fi 20 | 21 | exec java -jar "$jar" -sharedDb -port 8002 22 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/branch.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Branch branch 17 | // 18 | // swagger:model Branch 19 | type Branch string 20 | 21 | const ( 22 | 23 | // BranchMaster captures enum value "master" 24 | BranchMaster Branch = "master" 25 | 26 | // BranchDEVBRANCH captures enum value "DEV_BRANCH" 27 | BranchDEVBRANCH Branch = "DEV_BRANCH" 28 | 29 | // BranchTest captures enum value "test" 30 | BranchTest Branch = "test" 31 | ) 32 | 33 | // for schema 34 | var branchEnum []interface{} 35 | 36 | func init() { 37 | var res []Branch 38 | if err := json.Unmarshal([]byte(`["master","DEV_BRANCH","test"]`), &res); err != nil { 39 | panic(err) 40 | } 41 | for _, v := range res { 42 | branchEnum = append(branchEnum, v) 43 | } 44 | } 45 | 46 | func (m Branch) validateBranchEnum(path, location string, value Branch) error { 47 | if err := validate.Enum(path, location, value, branchEnum); err != nil { 48 | return err 49 | } 50 | return nil 51 | } 52 | 53 | // Validate validates this branch 54 | func (m Branch) Validate(formats strfmt.Registry) error { 55 | var res []error 56 | 57 | // value enum 58 | if err := m.validateBranchEnum("", "body", m); err != nil { 59 | return err 60 | } 61 | 62 | if len(res) > 0 { 63 | return errors.CompositeValidationError(res...) 64 | } 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/category.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Category category 17 | // 18 | // swagger:model Category 19 | type Category string 20 | 21 | const ( 22 | 23 | // CategoryA captures enum value "a" 24 | CategoryA Category = "a" 25 | 26 | // CategoryB captures enum value "b" 27 | CategoryB Category = "b" 28 | ) 29 | 30 | // for schema 31 | var categoryEnum []interface{} 32 | 33 | func init() { 34 | var res []Category 35 | if err := json.Unmarshal([]byte(`["a","b"]`), &res); err != nil { 36 | panic(err) 37 | } 38 | for _, v := range res { 39 | categoryEnum = append(categoryEnum, v) 40 | } 41 | } 42 | 43 | func (m Category) validateCategoryEnum(path, location string, value Category) error { 44 | if err := validate.Enum(path, location, value, categoryEnum); err != nil { 45 | return err 46 | } 47 | return nil 48 | } 49 | 50 | // Validate validates this category 51 | func (m Category) Validate(formats strfmt.Registry) error { 52 | var res []error 53 | 54 | // value enum 55 | if err := m.validateCategoryEnum("", "body", m); err != nil { 56 | return err 57 | } 58 | 59 | if len(res) > 0 { 60 | return errors.CompositeValidationError(res...) 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/event.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Event event 14 | // 15 | // swagger:model Event 16 | type Event struct { 17 | 18 | // data 19 | // Format: byte 20 | Data strfmt.Base64 `json:"data,omitempty"` 21 | 22 | // pk 23 | Pk string `json:"pk,omitempty"` 24 | 25 | // sk 26 | Sk string `json:"sk,omitempty"` 27 | 28 | // ttl 29 | TTL int64 `json:"ttl,omitempty"` 30 | } 31 | 32 | // Validate validates this event 33 | func (m *Event) Validate(formats strfmt.Registry) error { 34 | return nil 35 | } 36 | 37 | // MarshalBinary interface implementation 38 | func (m *Event) MarshalBinary() ([]byte, error) { 39 | if m == nil { 40 | return nil, nil 41 | } 42 | return swag.WriteJSON(m) 43 | } 44 | 45 | // UnmarshalBinary interface implementation 46 | func (m *Event) UnmarshalBinary(b []byte) error { 47 | var res Event 48 | if err := swag.ReadJSON(b, &res); err != nil { 49 | return err 50 | } 51 | *m = res 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-db-custom-path/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // HealthCheckInput holds the input parameters for a healthCheck operation. 24 | type HealthCheckInput struct { 25 | } 26 | 27 | // Validate returns an error if any of the HealthCheckInput parameters don't satisfy the 28 | // requirements from the swagger yml file. 29 | func (i HealthCheckInput) Validate() error { 30 | return nil 31 | } 32 | 33 | // Path returns the URI path for the input. 34 | func (i HealthCheckInput) Path() (string, error) { 35 | path := "/v1/health/check" 36 | urlVals := url.Values{} 37 | 38 | return path + "?" + urlVals.Encode(), nil 39 | } 40 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/object.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Object object 14 | // 15 | // swagger:model Object 16 | type Object struct { 17 | 18 | // bar 19 | Bar string `json:"bar,omitempty"` 20 | 21 | // foo 22 | Foo string `json:"foo,omitempty"` 23 | } 24 | 25 | // Validate validates this object 26 | func (m *Object) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Object) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Object) UnmarshalBinary(b []byte) error { 40 | var res Object 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // SimpleThing simple thing 14 | // 15 | // swagger:model SimpleThing 16 | type SimpleThing struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | } 24 | 25 | // Validate validates this simple thing 26 | func (m *SimpleThing) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *SimpleThing) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *SimpleThing) UnmarshalBinary(b []byte) error { 40 | var res SimpleThing 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/teacher_sharing_rule.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // TeacherSharingRule teacher sharing rule 14 | // 15 | // swagger:model TeacherSharingRule 16 | type TeacherSharingRule struct { 17 | 18 | // app 19 | App string `json:"app,omitempty"` 20 | 21 | // district 22 | District string `json:"district,omitempty"` 23 | 24 | // id 25 | ID string `json:"id,omitempty"` 26 | 27 | // school 28 | School string `json:"school,omitempty"` 29 | 30 | // sections 31 | Sections []string `json:"sections"` 32 | 33 | // teacher 34 | Teacher string `json:"teacher,omitempty"` 35 | } 36 | 37 | // Validate validates this teacher sharing rule 38 | func (m *TeacherSharingRule) Validate(formats strfmt.Registry) error { 39 | return nil 40 | } 41 | 42 | // MarshalBinary interface implementation 43 | func (m *TeacherSharingRule) MarshalBinary() ([]byte, error) { 44 | if m == nil { 45 | return nil, nil 46 | } 47 | return swag.WriteJSON(m) 48 | } 49 | 50 | // UnmarshalBinary interface implementation 51 | func (m *TeacherSharingRule) UnmarshalBinary(b []byte) error { 52 | var res TeacherSharingRule 53 | if err := swag.ReadJSON(b, &res); err != nil { 54 | return err 55 | } 56 | *m = res 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/thing_with_transaction.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransaction thing with transaction 14 | // 15 | // swagger:model ThingWithTransaction 16 | type ThingWithTransaction struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction 23 | func (m *ThingWithTransaction) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransaction) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransaction) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransaction 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/thing_with_transaction_with_simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransactionWithSimpleThing thing with transaction with simple thing 14 | // 15 | // swagger:model ThingWithTransactionWithSimpleThing 16 | type ThingWithTransactionWithSimpleThing struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction with simple thing 23 | func (m *ThingWithTransactionWithSimpleThing) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransactionWithSimpleThing) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransactionWithSimpleThing) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransactionWithSimpleThing 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/thing_with_underscores.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithUnderscores thing with underscores 14 | // 15 | // swagger:model ThingWithUnderscores 16 | type ThingWithUnderscores struct { 17 | 18 | // id app 19 | IDApp string `json:"id_app,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with underscores 23 | func (m *ThingWithUnderscores) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithUnderscores) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithUnderscores) UnmarshalBinary(b []byte) error { 37 | var res ThingWithUnderscores 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-db-custom-path/models/v9 8 | 9 | // Controller defines the interface for the swagger-test service. 10 | type Controller interface { 11 | 12 | // HealthCheck handles GET requests to /health/check 13 | // 14 | // 200: nil 15 | // 400: *models.BadRequest 16 | // 500: *models.InternalError 17 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 18 | HealthCheck(ctx context.Context) error 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-db-custom-path/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | gomock "github.com/golang/mock/gomock" 12 | ) 13 | 14 | // MockController is a mock of Controller interface. 15 | type MockController struct { 16 | ctrl *gomock.Controller 17 | recorder *MockControllerMockRecorder 18 | } 19 | 20 | // MockControllerMockRecorder is the mock recorder for MockController. 21 | type MockControllerMockRecorder struct { 22 | mock *MockController 23 | } 24 | 25 | // NewMockController creates a new mock instance. 26 | func NewMockController(ctrl *gomock.Controller) *MockController { 27 | mock := &MockController{ctrl: ctrl} 28 | mock.recorder = &MockControllerMockRecorder{mock} 29 | return mock 30 | } 31 | 32 | // EXPECT returns an object that allows the caller to indicate expected use. 33 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 34 | return m.recorder 35 | } 36 | 37 | // HealthCheck mocks base method. 38 | func (m *MockController) HealthCheck(ctx context.Context) error { 39 | m.ctrl.T.Helper() 40 | ret := m.ctrl.Call(m, "HealthCheck", ctx) 41 | ret0, _ := ret[0].(error) 42 | return ret0 43 | } 44 | 45 | // HealthCheck indicates an expected call of HealthCheck. 46 | func (mr *MockControllerMockRecorder) HealthCheck(ctx interface{}) *gomock.Call { 47 | mr.mock.ctrl.T.Helper() 48 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthCheck", reflect.TypeOf((*MockController)(nil).HealthCheck), ctx) 49 | } 50 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/db/dynamodb/dynamodb-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | jar=/tmp/DynamoDBLocal.jar 6 | 7 | # download the dynamo jar if necessary 8 | if [ ! -e "$jar" ] 9 | then 10 | if [ `uname` = "Darwin" ] ; then 11 | # this will prompt for java to be installed if necessary 12 | java -version 13 | else 14 | sudo apt-get update && sudo apt-get install -y default-jre 15 | fi 16 | echo "Downloading dynamodb-local..." 17 | curl -L -k --url https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -o /tmp/dynamodb_local_latest.tar.gz 18 | tar -zxvf /tmp/dynamodb_local_latest.tar.gz -C /tmp/ 19 | fi 20 | 21 | exec java -jar "$jar" -sharedDb -port 8002 22 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/branch.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Branch branch 17 | // 18 | // swagger:model Branch 19 | type Branch string 20 | 21 | const ( 22 | 23 | // BranchMaster captures enum value "master" 24 | BranchMaster Branch = "master" 25 | 26 | // BranchDEVBRANCH captures enum value "DEV_BRANCH" 27 | BranchDEVBRANCH Branch = "DEV_BRANCH" 28 | 29 | // BranchTest captures enum value "test" 30 | BranchTest Branch = "test" 31 | ) 32 | 33 | // for schema 34 | var branchEnum []interface{} 35 | 36 | func init() { 37 | var res []Branch 38 | if err := json.Unmarshal([]byte(`["master","DEV_BRANCH","test"]`), &res); err != nil { 39 | panic(err) 40 | } 41 | for _, v := range res { 42 | branchEnum = append(branchEnum, v) 43 | } 44 | } 45 | 46 | func (m Branch) validateBranchEnum(path, location string, value Branch) error { 47 | if err := validate.Enum(path, location, value, branchEnum); err != nil { 48 | return err 49 | } 50 | return nil 51 | } 52 | 53 | // Validate validates this branch 54 | func (m Branch) Validate(formats strfmt.Registry) error { 55 | var res []error 56 | 57 | // value enum 58 | if err := m.validateBranchEnum("", "body", m); err != nil { 59 | return err 60 | } 61 | 62 | if len(res) > 0 { 63 | return errors.CompositeValidationError(res...) 64 | } 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/category.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Category category 17 | // 18 | // swagger:model Category 19 | type Category string 20 | 21 | const ( 22 | 23 | // CategoryA captures enum value "a" 24 | CategoryA Category = "a" 25 | 26 | // CategoryB captures enum value "b" 27 | CategoryB Category = "b" 28 | ) 29 | 30 | // for schema 31 | var categoryEnum []interface{} 32 | 33 | func init() { 34 | var res []Category 35 | if err := json.Unmarshal([]byte(`["a","b"]`), &res); err != nil { 36 | panic(err) 37 | } 38 | for _, v := range res { 39 | categoryEnum = append(categoryEnum, v) 40 | } 41 | } 42 | 43 | func (m Category) validateCategoryEnum(path, location string, value Category) error { 44 | if err := validate.Enum(path, location, value, categoryEnum); err != nil { 45 | return err 46 | } 47 | return nil 48 | } 49 | 50 | // Validate validates this category 51 | func (m Category) Validate(formats strfmt.Registry) error { 52 | var res []error 53 | 54 | // value enum 55 | if err := m.validateCategoryEnum("", "body", m); err != nil { 56 | return err 57 | } 58 | 59 | if len(res) > 0 { 60 | return errors.CompositeValidationError(res...) 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/event.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Event event 14 | // 15 | // swagger:model Event 16 | type Event struct { 17 | 18 | // data 19 | // Format: byte 20 | Data strfmt.Base64 `json:"data,omitempty"` 21 | 22 | // pk 23 | Pk string `json:"pk,omitempty"` 24 | 25 | // sk 26 | Sk string `json:"sk,omitempty"` 27 | 28 | // ttl 29 | TTL int64 `json:"ttl,omitempty"` 30 | } 31 | 32 | // Validate validates this event 33 | func (m *Event) Validate(formats strfmt.Registry) error { 34 | return nil 35 | } 36 | 37 | // MarshalBinary interface implementation 38 | func (m *Event) MarshalBinary() ([]byte, error) { 39 | if m == nil { 40 | return nil, nil 41 | } 42 | return swag.WriteJSON(m) 43 | } 44 | 45 | // UnmarshalBinary interface implementation 46 | func (m *Event) UnmarshalBinary(b []byte) error { 47 | var res Event 48 | if err := swag.ReadJSON(b, &res); err != nil { 49 | return err 50 | } 51 | *m = res 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-db-only/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // HealthCheckInput holds the input parameters for a healthCheck operation. 24 | type HealthCheckInput struct { 25 | } 26 | 27 | // Validate returns an error if any of the HealthCheckInput parameters don't satisfy the 28 | // requirements from the swagger yml file. 29 | func (i HealthCheckInput) Validate() error { 30 | return nil 31 | } 32 | 33 | // Path returns the URI path for the input. 34 | func (i HealthCheckInput) Path() (string, error) { 35 | path := "/v1/health/check" 36 | urlVals := url.Values{} 37 | 38 | return path + "?" + urlVals.Encode(), nil 39 | } 40 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/object.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Object object 14 | // 15 | // swagger:model Object 16 | type Object struct { 17 | 18 | // bar 19 | Bar string `json:"bar,omitempty"` 20 | 21 | // foo 22 | Foo string `json:"foo,omitempty"` 23 | } 24 | 25 | // Validate validates this object 26 | func (m *Object) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Object) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Object) UnmarshalBinary(b []byte) error { 40 | var res Object 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // SimpleThing simple thing 14 | // 15 | // swagger:model SimpleThing 16 | type SimpleThing struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | } 24 | 25 | // Validate validates this simple thing 26 | func (m *SimpleThing) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *SimpleThing) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *SimpleThing) UnmarshalBinary(b []byte) error { 40 | var res SimpleThing 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/teacher_sharing_rule.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // TeacherSharingRule teacher sharing rule 14 | // 15 | // swagger:model TeacherSharingRule 16 | type TeacherSharingRule struct { 17 | 18 | // app 19 | App string `json:"app,omitempty"` 20 | 21 | // district 22 | District string `json:"district,omitempty"` 23 | 24 | // id 25 | ID string `json:"id,omitempty"` 26 | 27 | // school 28 | School string `json:"school,omitempty"` 29 | 30 | // sections 31 | Sections []string `json:"sections"` 32 | 33 | // teacher 34 | Teacher string `json:"teacher,omitempty"` 35 | } 36 | 37 | // Validate validates this teacher sharing rule 38 | func (m *TeacherSharingRule) Validate(formats strfmt.Registry) error { 39 | return nil 40 | } 41 | 42 | // MarshalBinary interface implementation 43 | func (m *TeacherSharingRule) MarshalBinary() ([]byte, error) { 44 | if m == nil { 45 | return nil, nil 46 | } 47 | return swag.WriteJSON(m) 48 | } 49 | 50 | // UnmarshalBinary interface implementation 51 | func (m *TeacherSharingRule) UnmarshalBinary(b []byte) error { 52 | var res TeacherSharingRule 53 | if err := swag.ReadJSON(b, &res); err != nil { 54 | return err 55 | } 56 | *m = res 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/thing_with_transaction.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransaction thing with transaction 14 | // 15 | // swagger:model ThingWithTransaction 16 | type ThingWithTransaction struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction 23 | func (m *ThingWithTransaction) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransaction) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransaction) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransaction 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/thing_with_transaction_with_simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransactionWithSimpleThing thing with transaction with simple thing 14 | // 15 | // swagger:model ThingWithTransactionWithSimpleThing 16 | type ThingWithTransactionWithSimpleThing struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction with simple thing 23 | func (m *ThingWithTransactionWithSimpleThing) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransactionWithSimpleThing) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransactionWithSimpleThing) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransactionWithSimpleThing 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/thing_with_underscores.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithUnderscores thing with underscores 14 | // 15 | // swagger:model ThingWithUnderscores 16 | type ThingWithUnderscores struct { 17 | 18 | // id app 19 | IDApp string `json:"id_app,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with underscores 23 | func (m *ThingWithUnderscores) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithUnderscores) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithUnderscores) UnmarshalBinary(b []byte) error { 37 | var res ThingWithUnderscores 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db-only/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-db/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-db/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-db/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-db/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-db/models/v9 8 | 9 | // Client defines the methods available to clients of the swagger-test service. 10 | type Client interface { 11 | 12 | // HealthCheck makes a GET request to /health/check 13 | // 14 | // 200: nil 15 | // 400: *models.BadRequest 16 | // 500: *models.InternalError 17 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 18 | HealthCheck(ctx context.Context) error 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/branch.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Branch branch 17 | // 18 | // swagger:model Branch 19 | type Branch string 20 | 21 | const ( 22 | 23 | // BranchMaster captures enum value "master" 24 | BranchMaster Branch = "master" 25 | 26 | // BranchDEVBRANCH captures enum value "DEV_BRANCH" 27 | BranchDEVBRANCH Branch = "DEV_BRANCH" 28 | 29 | // BranchTest captures enum value "test" 30 | BranchTest Branch = "test" 31 | ) 32 | 33 | // for schema 34 | var branchEnum []interface{} 35 | 36 | func init() { 37 | var res []Branch 38 | if err := json.Unmarshal([]byte(`["master","DEV_BRANCH","test"]`), &res); err != nil { 39 | panic(err) 40 | } 41 | for _, v := range res { 42 | branchEnum = append(branchEnum, v) 43 | } 44 | } 45 | 46 | func (m Branch) validateBranchEnum(path, location string, value Branch) error { 47 | if err := validate.Enum(path, location, value, branchEnum); err != nil { 48 | return err 49 | } 50 | return nil 51 | } 52 | 53 | // Validate validates this branch 54 | func (m Branch) Validate(formats strfmt.Registry) error { 55 | var res []error 56 | 57 | // value enum 58 | if err := m.validateBranchEnum("", "body", m); err != nil { 59 | return err 60 | } 61 | 62 | if len(res) > 0 { 63 | return errors.CompositeValidationError(res...) 64 | } 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/category.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "encoding/json" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/strfmt" 13 | "github.com/go-openapi/validate" 14 | ) 15 | 16 | // Category category 17 | // 18 | // swagger:model Category 19 | type Category string 20 | 21 | const ( 22 | 23 | // CategoryA captures enum value "a" 24 | CategoryA Category = "a" 25 | 26 | // CategoryB captures enum value "b" 27 | CategoryB Category = "b" 28 | ) 29 | 30 | // for schema 31 | var categoryEnum []interface{} 32 | 33 | func init() { 34 | var res []Category 35 | if err := json.Unmarshal([]byte(`["a","b"]`), &res); err != nil { 36 | panic(err) 37 | } 38 | for _, v := range res { 39 | categoryEnum = append(categoryEnum, v) 40 | } 41 | } 42 | 43 | func (m Category) validateCategoryEnum(path, location string, value Category) error { 44 | if err := validate.Enum(path, location, value, categoryEnum); err != nil { 45 | return err 46 | } 47 | return nil 48 | } 49 | 50 | // Validate validates this category 51 | func (m Category) Validate(formats strfmt.Registry) error { 52 | var res []error 53 | 54 | // value enum 55 | if err := m.validateCategoryEnum("", "body", m); err != nil { 56 | return err 57 | } 58 | 59 | if len(res) > 0 { 60 | return errors.CompositeValidationError(res...) 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/event.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Event event 14 | // 15 | // swagger:model Event 16 | type Event struct { 17 | 18 | // data 19 | // Format: byte 20 | Data strfmt.Base64 `json:"data,omitempty"` 21 | 22 | // pk 23 | Pk string `json:"pk,omitempty"` 24 | 25 | // sk 26 | Sk string `json:"sk,omitempty"` 27 | 28 | // ttl 29 | TTL int64 `json:"ttl,omitempty"` 30 | } 31 | 32 | // Validate validates this event 33 | func (m *Event) Validate(formats strfmt.Registry) error { 34 | return nil 35 | } 36 | 37 | // MarshalBinary interface implementation 38 | func (m *Event) MarshalBinary() ([]byte, error) { 39 | if m == nil { 40 | return nil, nil 41 | } 42 | return swag.WriteJSON(m) 43 | } 44 | 45 | // UnmarshalBinary interface implementation 46 | func (m *Event) UnmarshalBinary(b []byte) error { 47 | var res Event 48 | if err := swag.ReadJSON(b, &res); err != nil { 49 | return err 50 | } 51 | *m = res 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-db/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/errors v0.20.2 7 | github.com/go-openapi/strfmt v0.21.2 8 | github.com/go-openapi/swag v0.21.1 9 | github.com/go-openapi/validate v0.22.0 10 | ) 11 | 12 | require ( 13 | github.com/PuerkitoBio/purell v1.1.1 // indirect 14 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 15 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 16 | github.com/go-openapi/analysis v0.21.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // HealthCheckInput holds the input parameters for a healthCheck operation. 24 | type HealthCheckInput struct { 25 | } 26 | 27 | // Validate returns an error if any of the HealthCheckInput parameters don't satisfy the 28 | // requirements from the swagger yml file. 29 | func (i HealthCheckInput) Validate() error { 30 | return nil 31 | } 32 | 33 | // Path returns the URI path for the input. 34 | func (i HealthCheckInput) Path() (string, error) { 35 | path := "/v1/health/check" 36 | urlVals := url.Values{} 37 | 38 | return path + "?" + urlVals.Encode(), nil 39 | } 40 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/object.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // Object object 14 | // 15 | // swagger:model Object 16 | type Object struct { 17 | 18 | // bar 19 | Bar string `json:"bar,omitempty"` 20 | 21 | // foo 22 | Foo string `json:"foo,omitempty"` 23 | } 24 | 25 | // Validate validates this object 26 | func (m *Object) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *Object) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *Object) UnmarshalBinary(b []byte) error { 40 | var res Object 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // SimpleThing simple thing 14 | // 15 | // swagger:model SimpleThing 16 | type SimpleThing struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // name 22 | Name string `json:"name,omitempty"` 23 | } 24 | 25 | // Validate validates this simple thing 26 | func (m *SimpleThing) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *SimpleThing) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *SimpleThing) UnmarshalBinary(b []byte) error { 40 | var res SimpleThing 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/teacher_sharing_rule.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // TeacherSharingRule teacher sharing rule 14 | // 15 | // swagger:model TeacherSharingRule 16 | type TeacherSharingRule struct { 17 | 18 | // app 19 | App string `json:"app,omitempty"` 20 | 21 | // district 22 | District string `json:"district,omitempty"` 23 | 24 | // id 25 | ID string `json:"id,omitempty"` 26 | 27 | // school 28 | School string `json:"school,omitempty"` 29 | 30 | // sections 31 | Sections []string `json:"sections"` 32 | 33 | // teacher 34 | Teacher string `json:"teacher,omitempty"` 35 | } 36 | 37 | // Validate validates this teacher sharing rule 38 | func (m *TeacherSharingRule) Validate(formats strfmt.Registry) error { 39 | return nil 40 | } 41 | 42 | // MarshalBinary interface implementation 43 | func (m *TeacherSharingRule) MarshalBinary() ([]byte, error) { 44 | if m == nil { 45 | return nil, nil 46 | } 47 | return swag.WriteJSON(m) 48 | } 49 | 50 | // UnmarshalBinary interface implementation 51 | func (m *TeacherSharingRule) UnmarshalBinary(b []byte) error { 52 | var res TeacherSharingRule 53 | if err := swag.ReadJSON(b, &res); err != nil { 54 | return err 55 | } 56 | *m = res 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/thing_with_transaction.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransaction thing with transaction 14 | // 15 | // swagger:model ThingWithTransaction 16 | type ThingWithTransaction struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction 23 | func (m *ThingWithTransaction) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransaction) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransaction) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransaction 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/thing_with_transaction_with_simple_thing.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithTransactionWithSimpleThing thing with transaction with simple thing 14 | // 15 | // swagger:model ThingWithTransactionWithSimpleThing 16 | type ThingWithTransactionWithSimpleThing struct { 17 | 18 | // name 19 | Name string `json:"name,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with transaction with simple thing 23 | func (m *ThingWithTransactionWithSimpleThing) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithTransactionWithSimpleThing) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithTransactionWithSimpleThing) UnmarshalBinary(b []byte) error { 37 | var res ThingWithTransactionWithSimpleThing 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/thing_with_underscores.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ThingWithUnderscores thing with underscores 14 | // 15 | // swagger:model ThingWithUnderscores 16 | type ThingWithUnderscores struct { 17 | 18 | // id app 19 | IDApp string `json:"id_app,omitempty"` 20 | } 21 | 22 | // Validate validates this thing with underscores 23 | func (m *ThingWithUnderscores) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *ThingWithUnderscores) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *ThingWithUnderscores) UnmarshalBinary(b []byte) error { 37 | var res ThingWithUnderscores 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-db/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-db/server/db/dynamodb/dynamodb-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | jar=/tmp/DynamoDBLocal.jar 6 | 7 | # download the dynamo jar if necessary 8 | if [ ! -e "$jar" ] 9 | then 10 | if [ `uname` = "Darwin" ] ; then 11 | # this will prompt for java to be installed if necessary 12 | java -version 13 | else 14 | sudo apt-get update && sudo apt-get install -y default-jre 15 | fi 16 | echo "Downloading dynamodb-local..." 17 | curl -L -k --url https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -o /tmp/dynamodb_local_latest.tar.gz 18 | tar -zxvf /tmp/dynamodb_local_latest.tar.gz -C /tmp/ 19 | fi 20 | 21 | exec java -jar "$jar" -sharedDb -port 8002 22 | -------------------------------------------------------------------------------- /samples/gen-go-db/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-db/models/v9 8 | 9 | // Controller defines the interface for the swagger-test service. 10 | type Controller interface { 11 | 12 | // HealthCheck handles GET requests to /health/check 13 | // 14 | // 200: nil 15 | // 400: *models.BadRequest 16 | // 500: *models.InternalError 17 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 18 | HealthCheck(ctx context.Context) error 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-db/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | gomock "github.com/golang/mock/gomock" 12 | ) 13 | 14 | // MockController is a mock of Controller interface. 15 | type MockController struct { 16 | ctrl *gomock.Controller 17 | recorder *MockControllerMockRecorder 18 | } 19 | 20 | // MockControllerMockRecorder is the mock recorder for MockController. 21 | type MockControllerMockRecorder struct { 22 | mock *MockController 23 | } 24 | 25 | // NewMockController creates a new mock instance. 26 | func NewMockController(ctrl *gomock.Controller) *MockController { 27 | mock := &MockController{ctrl: ctrl} 28 | mock.recorder = &MockControllerMockRecorder{mock} 29 | return mock 30 | } 31 | 32 | // EXPECT returns an object that allows the caller to indicate expected use. 33 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 34 | return m.recorder 35 | } 36 | 37 | // HealthCheck mocks base method. 38 | func (m *MockController) HealthCheck(ctx context.Context) error { 39 | m.ctrl.T.Helper() 40 | ret := m.ctrl.Call(m, "HealthCheck", ctx) 41 | ret0, _ := ret[0].(error) 42 | return ret0 43 | } 44 | 45 | // HealthCheck indicates an expected call of HealthCheck. 46 | func (mr *MockControllerMockRecorder) HealthCheck(ctx interface{}) *gomock.Call { 47 | mr.mock.ctrl.T.Helper() 48 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthCheck", reflect.TypeOf((*MockController)(nil).HealthCheck), ctx) 49 | } 50 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-deprecated/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-deprecated/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-deprecated/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-deprecated/models/v9 4 | 5 | // Client defines the methods available to clients of the swagger-test service. 6 | type Client interface { 7 | } 8 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-deprecated/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/strfmt v0.21.2 7 | github.com/go-openapi/swag v0.21.1 8 | github.com/go-openapi/validate v0.22.0 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // HealthInput holds the input parameters for a health operation. 24 | type HealthInput struct { 25 | Section int64 26 | } 27 | 28 | // Validate returns an error if any of the HealthInput parameters don't satisfy the 29 | // requirements from the swagger yml file. 30 | func (i HealthInput) Validate() error { 31 | 32 | return nil 33 | } 34 | 35 | // Path returns the URI path for the input. 36 | func (i HealthInput) Path() (string, error) { 37 | path := "/v1/health" 38 | urlVals := url.Values{} 39 | 40 | urlVals.Add("section", strconv.FormatInt(i.Section, 10)) 41 | 42 | return path + "?" + urlVals.Encode(), nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/not_found.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // NotFound not found 14 | // 15 | // swagger:model NotFound 16 | type NotFound struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this not found 23 | func (m *NotFound) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *NotFound) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *NotFound) UnmarshalBinary(b []byte) error { 37 | var res NotFound 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (o NotFound) Error() string { 14 | return o.Message 15 | } 16 | 17 | func (u UnknownResponse) Error() string { 18 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-deprecated/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-deprecated/models/v9 10 | 11 | // Controller defines the interface for the swagger-test service. 12 | type Controller interface { 13 | 14 | // Health handles GET requests to /health 15 | // 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 404: *models.NotFound 19 | // 500: *models.InternalError 20 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 21 | Health(ctx context.Context, i *models.HealthInput) error 22 | } 23 | -------------------------------------------------------------------------------- /samples/gen-go-deprecated/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | models "github.com/Clever/wag/samples/gen-go-deprecated/models/v9" 12 | gomock "github.com/golang/mock/gomock" 13 | ) 14 | 15 | // MockController is a mock of Controller interface. 16 | type MockController struct { 17 | ctrl *gomock.Controller 18 | recorder *MockControllerMockRecorder 19 | } 20 | 21 | // MockControllerMockRecorder is the mock recorder for MockController. 22 | type MockControllerMockRecorder struct { 23 | mock *MockController 24 | } 25 | 26 | // NewMockController creates a new mock instance. 27 | func NewMockController(ctrl *gomock.Controller) *MockController { 28 | mock := &MockController{ctrl: ctrl} 29 | mock.recorder = &MockControllerMockRecorder{mock} 30 | return mock 31 | } 32 | 33 | // EXPECT returns an object that allows the caller to indicate expected use. 34 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 35 | return m.recorder 36 | } 37 | 38 | // Health mocks base method. 39 | func (m *MockController) Health(ctx context.Context, i *models.HealthInput) error { 40 | m.ctrl.T.Helper() 41 | ret := m.ctrl.Call(m, "Health", ctx, i) 42 | ret0, _ := ret[0].(error) 43 | return ret0 44 | } 45 | 46 | // Health indicates an expected call of Health. 47 | func (mr *MockControllerMockRecorder) Health(ctx, i interface{}) *gomock.Call { 48 | mr.mock.ctrl.T.Helper() 49 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Health", reflect.TypeOf((*MockController)(nil).Health), ctx, i) 50 | } 51 | -------------------------------------------------------------------------------- /samples/gen-go-errors/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-errors/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-errors/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-errors/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-errors/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-errors/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-errors/models/v9 10 | 11 | // Client defines the methods available to clients of the swagger-test service. 12 | type Client interface { 13 | 14 | // GetBook makes a GET request to /books/{id} 15 | // 16 | // 200: nil 17 | // 400: *models.ExtendedError 18 | // 404: *models.NotFound 19 | // 500: *models.InternalError 20 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 21 | GetBook(ctx context.Context, i *models.GetBookInput) error 22 | } 23 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/extended_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // ExtendedError extended error 14 | // 15 | // swagger:model ExtendedError 16 | type ExtendedError struct { 17 | 18 | // code 19 | Code int64 `json:"code,omitempty"` 20 | 21 | // message 22 | Message string `json:"message,omitempty"` 23 | } 24 | 25 | // Validate validates this extended error 26 | func (m *ExtendedError) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *ExtendedError) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *ExtendedError) UnmarshalBinary(b []byte) error { 40 | var res ExtendedError 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-errors/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/strfmt v0.21.2 7 | github.com/go-openapi/swag v0.21.1 8 | github.com/go-openapi/validate v0.22.0 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // GetBookInput holds the input parameters for a getBook operation. 24 | type GetBookInput struct { 25 | ID int64 26 | } 27 | 28 | // Validate returns an error if any of the GetBookInput parameters don't satisfy the 29 | // requirements from the swagger yml file. 30 | func (i GetBookInput) Validate() error { 31 | 32 | if err := validate.MaximumInt("id", "path", i.ID, int64(4000), false); err != nil { 33 | return err 34 | } 35 | 36 | return nil 37 | } 38 | 39 | // Path returns the URI path for the input. 40 | func (i GetBookInput) Path() (string, error) { 41 | path := "/v1/books/{id}" 42 | urlVals := url.Values{} 43 | 44 | pathid := strconv.FormatInt(i.ID, 10) 45 | if pathid == "" { 46 | err := fmt.Errorf("id cannot be empty because it's a path parameter") 47 | if err != nil { 48 | return "", err 49 | } 50 | } 51 | path = strings.Replace(path, "{id}", pathid, -1) 52 | 53 | return path + "?" + urlVals.Encode(), nil 54 | } 55 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // code 19 | Code int64 `json:"code,omitempty"` 20 | 21 | // message 22 | Message string `json:"message,omitempty"` 23 | } 24 | 25 | // Validate validates this internal error 26 | func (m *InternalError) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *InternalError) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *InternalError) UnmarshalBinary(b []byte) error { 40 | var res InternalError 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/not_found.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // NotFound not found 14 | // 15 | // swagger:model NotFound 16 | type NotFound struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this not found 23 | func (m *NotFound) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *NotFound) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *NotFound) UnmarshalBinary(b []byte) error { 37 | var res NotFound 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o ExtendedError) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (o NotFound) Error() string { 14 | return o.Message 15 | } 16 | 17 | func (u UnknownResponse) Error() string { 18 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 19 | } 20 | -------------------------------------------------------------------------------- /samples/gen-go-errors/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-errors/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-errors/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-errors/models/v9 10 | 11 | // Controller defines the interface for the swagger-test service. 12 | type Controller interface { 13 | 14 | // GetBook handles GET requests to /books/{id} 15 | // 16 | // 200: nil 17 | // 400: *models.ExtendedError 18 | // 404: *models.NotFound 19 | // 500: *models.InternalError 20 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 21 | GetBook(ctx context.Context, i *models.GetBookInput) error 22 | } 23 | -------------------------------------------------------------------------------- /samples/gen-go-errors/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | models "github.com/Clever/wag/samples/gen-go-errors/models/v9" 12 | gomock "github.com/golang/mock/gomock" 13 | ) 14 | 15 | // MockController is a mock of Controller interface. 16 | type MockController struct { 17 | ctrl *gomock.Controller 18 | recorder *MockControllerMockRecorder 19 | } 20 | 21 | // MockControllerMockRecorder is the mock recorder for MockController. 22 | type MockControllerMockRecorder struct { 23 | mock *MockController 24 | } 25 | 26 | // NewMockController creates a new mock instance. 27 | func NewMockController(ctrl *gomock.Controller) *MockController { 28 | mock := &MockController{ctrl: ctrl} 29 | mock.recorder = &MockControllerMockRecorder{mock} 30 | return mock 31 | } 32 | 33 | // EXPECT returns an object that allows the caller to indicate expected use. 34 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 35 | return m.recorder 36 | } 37 | 38 | // GetBook mocks base method. 39 | func (m *MockController) GetBook(ctx context.Context, i *models.GetBookInput) error { 40 | m.ctrl.T.Helper() 41 | ret := m.ctrl.Call(m, "GetBook", ctx, i) 42 | ret0, _ := ret[0].(error) 43 | return ret0 44 | } 45 | 46 | // GetBook indicates an expected call of GetBook. 47 | func (mr *MockControllerMockRecorder) GetBook(ctx, i interface{}) *gomock.Call { 48 | mr.mock.ctrl.T.Helper() 49 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBook", reflect.TypeOf((*MockController)(nil).GetBook), ctx, i) 50 | } 51 | -------------------------------------------------------------------------------- /samples/gen-go-nils/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-nils/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-nils/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-nils/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-nils/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-nils/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-nils/models/v9 10 | 11 | // Client defines the methods available to clients of the nil-test service. 12 | type Client interface { 13 | 14 | // NilCheck makes a POST request to /check/{id} 15 | // Nil check tests 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | NilCheck(ctx context.Context, i *models.NilCheckInput) error 21 | } 22 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-nils/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/strfmt v0.21.2 7 | github.com/go-openapi/swag v0.21.1 8 | github.com/go-openapi/validate v0.22.0 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/inputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/validate" 12 | ) 13 | 14 | // These imports may not be used depending on the input parameters 15 | var _ = json.Marshal 16 | var _ = fmt.Sprintf 17 | var _ = url.QueryEscape 18 | var _ = strconv.FormatInt 19 | var _ = strings.Replace 20 | var _ = validate.Maximum 21 | var _ = strfmt.NewFormats 22 | 23 | // NilCheckInput holds the input parameters for a nilCheck operation. 24 | type NilCheckInput struct { 25 | ID string 26 | Query *string 27 | Header string 28 | Array []string 29 | Body *NilFields 30 | } 31 | 32 | // Validate returns an error if any of the NilCheckInput parameters don't satisfy the 33 | // requirements from the swagger yml file. 34 | func (i NilCheckInput) Validate() error { 35 | 36 | if i.Body != nil { 37 | if err := i.Body.Validate(nil); err != nil { 38 | return err 39 | } 40 | } 41 | return nil 42 | } 43 | 44 | // Path returns the URI path for the input. 45 | func (i NilCheckInput) Path() (string, error) { 46 | path := "/v1/check/{id}" 47 | urlVals := url.Values{} 48 | 49 | pathid := i.ID 50 | if pathid == "" { 51 | err := fmt.Errorf("id cannot be empty because it's a path parameter") 52 | if err != nil { 53 | return "", err 54 | } 55 | } 56 | path = strings.Replace(path, "{id}", pathid, -1) 57 | 58 | if i.Query != nil { 59 | urlVals.Add("query", *i.Query) 60 | } 61 | 62 | for _, v := range i.Array { 63 | urlVals.Add("array", v) 64 | } 65 | 66 | return path + "?" + urlVals.Encode(), nil 67 | } 68 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/nil_fields.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // NilFields nil fields 14 | // 15 | // swagger:model NilFields 16 | type NilFields struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // optional 22 | Optional *string `json:"optional,omitempty"` 23 | } 24 | 25 | // Validate validates this nil fields 26 | func (m *NilFields) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *NilFields) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *NilFields) UnmarshalBinary(b []byte) error { 40 | var res NilFields 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-nils/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-nils/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-nils/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-nils/models/v9 10 | 11 | // Controller defines the interface for the nil-test service. 12 | type Controller interface { 13 | 14 | // NilCheck handles POST requests to /check/{id} 15 | // Nil check tests 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | NilCheck(ctx context.Context, i *models.NilCheckInput) error 21 | } 22 | -------------------------------------------------------------------------------- /samples/gen-go-nils/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | models "github.com/Clever/wag/samples/gen-go-nils/models/v9" 12 | gomock "github.com/golang/mock/gomock" 13 | ) 14 | 15 | // MockController is a mock of Controller interface. 16 | type MockController struct { 17 | ctrl *gomock.Controller 18 | recorder *MockControllerMockRecorder 19 | } 20 | 21 | // MockControllerMockRecorder is the mock recorder for MockController. 22 | type MockControllerMockRecorder struct { 23 | mock *MockController 24 | } 25 | 26 | // NewMockController creates a new mock instance. 27 | func NewMockController(ctrl *gomock.Controller) *MockController { 28 | mock := &MockController{ctrl: ctrl} 29 | mock.recorder = &MockControllerMockRecorder{mock} 30 | return mock 31 | } 32 | 33 | // EXPECT returns an object that allows the caller to indicate expected use. 34 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 35 | return m.recorder 36 | } 37 | 38 | // NilCheck mocks base method. 39 | func (m *MockController) NilCheck(ctx context.Context, i *models.NilCheckInput) error { 40 | m.ctrl.T.Helper() 41 | ret := m.ctrl.Call(m, "NilCheck", ctx, i) 42 | ret0, _ := ret[0].(error) 43 | return ret0 44 | } 45 | 46 | // NilCheck indicates an expected call of NilCheck. 47 | func (mr *MockControllerMockRecorder) NilCheck(ctx, i interface{}) *gomock.Call { 48 | mr.mock.ctrl.T.Helper() 49 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NilCheck", reflect.TypeOf((*MockController)(nil).NilCheck), ctx, i) 50 | } 51 | -------------------------------------------------------------------------------- /samples/gen-go-strings/client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-strings/client/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/Clever/discovery-go v1.8.1 7 | github.com/Clever/wag/logging/wagclientlogger v0.0.0-20221024182247-2bf828ef51be 8 | github.com/Clever/wag/samples/gen-go-strings/models/v9 v9.0.0-00010101000000-000000000000 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-openapi/strfmt v0.21.2 // indirect 22 | github.com/go-openapi/swag v0.21.1 // indirect 23 | github.com/go-openapi/validate v0.22.0 // indirect 24 | github.com/go-stack/stack v1.8.0 // indirect 25 | github.com/josharian/intern v1.0.0 // indirect 26 | github.com/mailru/easyjson v0.7.6 // indirect 27 | github.com/mitchellh/mapstructure v1.4.1 // indirect 28 | github.com/oklog/ulid v1.3.1 // indirect 29 | go.mongodb.org/mongo-driver v1.7.5 // indirect 30 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 31 | golang.org/x/text v0.3.7 // indirect 32 | gopkg.in/yaml.v2 v2.4.0 // indirect 33 | ) 34 | 35 | //Replace directives will work locally but mess up imports. 36 | replace github.com/Clever/wag/samples/gen-go-strings/models/v9 => ../models 37 | -------------------------------------------------------------------------------- /samples/gen-go-strings/client/interface.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-strings/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_client.go -package client --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-strings/models/v9 10 | 11 | // Client defines the methods available to clients of the nil-test service. 12 | type Client interface { 13 | 14 | // GetDistricts makes a POST request to /check 15 | // 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | GetDistricts(ctx context.Context, i *models.GetDistrictsInput) error 21 | } 22 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/bad_request.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // BadRequest bad request 14 | // 15 | // swagger:model BadRequest 16 | type BadRequest struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this bad request 23 | func (m *BadRequest) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *BadRequest) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *BadRequest) UnmarshalBinary(b []byte) error { 37 | var res BadRequest 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/samples/gen-go-strings/models/v9 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/go-openapi/strfmt v0.21.2 7 | github.com/go-openapi/swag v0.21.1 8 | github.com/go-openapi/validate v0.22.0 9 | ) 10 | 11 | require ( 12 | github.com/PuerkitoBio/purell v1.1.1 // indirect 13 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect 14 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 15 | github.com/go-openapi/analysis v0.21.2 // indirect 16 | github.com/go-openapi/errors v0.20.2 // indirect 17 | github.com/go-openapi/jsonpointer v0.19.5 // indirect 18 | github.com/go-openapi/jsonreference v0.19.6 // indirect 19 | github.com/go-openapi/loads v0.21.1 // indirect 20 | github.com/go-openapi/spec v0.20.4 // indirect 21 | github.com/go-stack/stack v1.8.0 // indirect 22 | github.com/google/go-cmp v0.5.5 // indirect 23 | github.com/google/uuid v1.1.2 // indirect 24 | github.com/josharian/intern v1.0.0 // indirect 25 | github.com/mailru/easyjson v0.7.6 // indirect 26 | github.com/mitchellh/mapstructure v1.4.1 // indirect 27 | github.com/oklog/ulid v1.3.1 // indirect 28 | go.mongodb.org/mongo-driver v1.7.5 // indirect 29 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect 30 | golang.org/x/text v0.3.7 // indirect 31 | gopkg.in/yaml.v2 v2.4.0 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/internal_error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // InternalError internal error 14 | // 15 | // swagger:model InternalError 16 | type InternalError struct { 17 | 18 | // message 19 | Message string `json:"message,omitempty"` 20 | } 21 | 22 | // Validate validates this internal error 23 | func (m *InternalError) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *InternalError) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *InternalError) UnmarshalBinary(b []byte) error { 37 | var res InternalError 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/nil_fields.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // NilFields nil fields 14 | // 15 | // swagger:model NilFields 16 | type NilFields struct { 17 | 18 | // id 19 | ID string `json:"id,omitempty"` 20 | 21 | // optional 22 | Optional *string `json:"optional,omitempty"` 23 | } 24 | 25 | // Validate validates this nil fields 26 | func (m *NilFields) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *NilFields) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *NilFields) UnmarshalBinary(b []byte) error { 40 | var res NilFields 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/outputs.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import "fmt" 4 | 5 | func (o BadRequest) Error() string { 6 | return o.Message 7 | } 8 | 9 | func (o InternalError) Error() string { 10 | return o.Message 11 | } 12 | 13 | func (u UnknownResponse) Error() string { 14 | return fmt.Sprintf("unknown response with status: %d body: %s", u.StatusCode, u.Body) 15 | } 16 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/unknown_response.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // UnknownResponse unknown response 14 | // 15 | // swagger:model UnknownResponse 16 | type UnknownResponse struct { 17 | 18 | // body 19 | Body string `json:"body,omitempty"` 20 | 21 | // status code 22 | StatusCode int64 `json:"statusCode,omitempty"` 23 | } 24 | 25 | // Validate validates this unknown response 26 | func (m *UnknownResponse) Validate(formats strfmt.Registry) error { 27 | return nil 28 | } 29 | 30 | // MarshalBinary interface implementation 31 | func (m *UnknownResponse) MarshalBinary() ([]byte, error) { 32 | if m == nil { 33 | return nil, nil 34 | } 35 | return swag.WriteJSON(m) 36 | } 37 | 38 | // UnmarshalBinary interface implementation 39 | func (m *UnknownResponse) UnmarshalBinary(b []byte) error { 40 | var res UnknownResponse 41 | if err := swag.ReadJSON(b, &res); err != nil { 42 | return err 43 | } 44 | *m = res 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /samples/gen-go-strings/models/where_query_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | ) 11 | 12 | // WhereQueryString where query string 13 | // 14 | // swagger:model WhereQueryString 15 | type WhereQueryString string 16 | 17 | // Validate validates this where query string 18 | func (m WhereQueryString) Validate(formats strfmt.Registry) error { 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /samples/gen-go-strings/server/interface.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/Clever/wag/samples/gen-go-strings/models/v9" 7 | ) 8 | 9 | //go:generate mockgen -source=$GOFILE -destination=mock_controller.go -package server --build_flags=--mod=mod -imports=models=github.com/Clever/wag/samples/gen-go-strings/models/v9 10 | 11 | // Controller defines the interface for the nil-test service. 12 | type Controller interface { 13 | 14 | // GetDistricts handles POST requests to /check 15 | // 16 | // 200: nil 17 | // 400: *models.BadRequest 18 | // 500: *models.InternalError 19 | // default: client side HTTP errors, for example: context.DeadlineExceeded. 20 | GetDistricts(ctx context.Context, i *models.GetDistrictsInput) error 21 | } 22 | -------------------------------------------------------------------------------- /samples/gen-go-strings/server/mock_controller.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: interface.go 3 | 4 | // Package server is a generated GoMock package. 5 | package server 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | models "github.com/Clever/wag/samples/gen-go-strings/models/v9" 12 | gomock "github.com/golang/mock/gomock" 13 | ) 14 | 15 | // MockController is a mock of Controller interface. 16 | type MockController struct { 17 | ctrl *gomock.Controller 18 | recorder *MockControllerMockRecorder 19 | } 20 | 21 | // MockControllerMockRecorder is the mock recorder for MockController. 22 | type MockControllerMockRecorder struct { 23 | mock *MockController 24 | } 25 | 26 | // NewMockController creates a new mock instance. 27 | func NewMockController(ctrl *gomock.Controller) *MockController { 28 | mock := &MockController{ctrl: ctrl} 29 | mock.recorder = &MockControllerMockRecorder{mock} 30 | return mock 31 | } 32 | 33 | // EXPECT returns an object that allows the caller to indicate expected use. 34 | func (m *MockController) EXPECT() *MockControllerMockRecorder { 35 | return m.recorder 36 | } 37 | 38 | // GetDistricts mocks base method. 39 | func (m *MockController) GetDistricts(ctx context.Context, i *models.GetDistrictsInput) error { 40 | m.ctrl.T.Helper() 41 | ret := m.ctrl.Call(m, "GetDistricts", ctx, i) 42 | ret0, _ := ret[0].(error) 43 | return ret0 44 | } 45 | 46 | // GetDistricts indicates an expected call of GetDistricts. 47 | func (mr *MockControllerMockRecorder) GetDistricts(ctx, i interface{}) *gomock.Call { 48 | mr.mock.ctrl.T.Helper() 49 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDistricts", reflect.TypeOf((*MockController)(nil).GetDistricts), ctx, i) 50 | } 51 | -------------------------------------------------------------------------------- /samples/gen-js-blog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog-example", 3 | "version": "9.0.0", 4 | "description": "Example for Blog", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-blog/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:blog 7 | * @alias module:blog.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:blog 23 | * @alias module:blog.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /samples/gen-js-client-only/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-client-only/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:swagger-test 23 | * @alias module:swagger-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | /** 36 | * Unathorized 37 | * @extends Error 38 | * @memberof module:swagger-test 39 | * @alias module:swagger-test.Errors.Unathorized 40 | * @property {string} message 41 | */ 42 | module.exports.Errors.Unathorized = class extends Error { 43 | constructor(body) { 44 | super(body.message); 45 | for (const k of Object.keys(body)) { 46 | this[k] = body[k]; 47 | } 48 | } 49 | }; 50 | 51 | /** 52 | * Error 53 | * @extends Error 54 | * @memberof module:swagger-test 55 | * @alias module:swagger-test.Errors.Error 56 | * @property {number} code 57 | * @property {string} message 58 | */ 59 | module.exports.Errors.Error = class extends Error { 60 | constructor(body) { 61 | super(body.message); 62 | for (const k of Object.keys(body)) { 63 | this[k] = body[k]; 64 | } 65 | } 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /samples/gen-js-db-custom-path/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-db-custom-path/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:swagger-test 23 | * @alias module:swagger-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /samples/gen-js-db/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-db/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:swagger-test 23 | * @alias module:swagger-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /samples/gen-js-deprecated/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-deprecated/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * NotFound 21 | * @extends Error 22 | * @memberof module:swagger-test 23 | * @alias module:swagger-test.Errors.NotFound 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.NotFound = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | /** 36 | * InternalError 37 | * @extends Error 38 | * @memberof module:swagger-test 39 | * @alias module:swagger-test.Errors.InternalError 40 | * @property {string} message 41 | */ 42 | module.exports.Errors.InternalError = class extends Error { 43 | constructor(body) { 44 | super(body.message); 45 | for (const k of Object.keys(body)) { 46 | this[k] = body[k]; 47 | } 48 | } 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /samples/gen-js-errors/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-errors/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * ExtendedError 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.ExtendedError 8 | * @property {number} code 9 | * @property {string} message 10 | */ 11 | module.exports.Errors.ExtendedError = class extends Error { 12 | constructor(body) { 13 | super(body.message); 14 | for (const k of Object.keys(body)) { 15 | this[k] = body[k]; 16 | } 17 | } 18 | }; 19 | 20 | /** 21 | * NotFound 22 | * @extends Error 23 | * @memberof module:swagger-test 24 | * @alias module:swagger-test.Errors.NotFound 25 | * @property {string} message 26 | */ 27 | module.exports.Errors.NotFound = class extends Error { 28 | constructor(body) { 29 | super(body.message); 30 | for (const k of Object.keys(body)) { 31 | this[k] = body[k]; 32 | } 33 | } 34 | }; 35 | 36 | /** 37 | * InternalError 38 | * @extends Error 39 | * @memberof module:swagger-test 40 | * @alias module:swagger-test.Errors.InternalError 41 | * @property {number} code 42 | * @property {string} message 43 | */ 44 | module.exports.Errors.InternalError = class extends Error { 45 | constructor(body) { 46 | super(body.message); 47 | for (const k of Object.keys(body)) { 48 | this[k] = body[k]; 49 | } 50 | } 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /samples/gen-js-nils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nil-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-nils/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:nil-test 7 | * @alias module:nil-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:nil-test 23 | * @alias module:nil-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /samples/gen-js-strings/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nil-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js-strings/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:nil-test 7 | * @alias module:nil-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:nil-test 23 | * @alias module:nil-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /samples/gen-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-test", 3 | "version": "9.0.0", 4 | "description": "Testing Swagger Codegen", 5 | "main": "index.js", 6 | "dependencies": { 7 | "async": "^2.1.4", 8 | "clever-discovery": "0.0.8", 9 | "request": "^2.87.0", 10 | "kayvee": "^3.13.0", 11 | "hystrixjs": "^0.2.0", 12 | "rxjs": "^5.4.1" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^3.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /samples/gen-js/types.js: -------------------------------------------------------------------------------- 1 | module.exports.Errors = {}; 2 | 3 | /** 4 | * BadRequest 5 | * @extends Error 6 | * @memberof module:swagger-test 7 | * @alias module:swagger-test.Errors.BadRequest 8 | * @property {string} message 9 | */ 10 | module.exports.Errors.BadRequest = class extends Error { 11 | constructor(body) { 12 | super(body.message); 13 | for (const k of Object.keys(body)) { 14 | this[k] = body[k]; 15 | } 16 | } 17 | }; 18 | 19 | /** 20 | * InternalError 21 | * @extends Error 22 | * @memberof module:swagger-test 23 | * @alias module:swagger-test.Errors.InternalError 24 | * @property {string} message 25 | */ 26 | module.exports.Errors.InternalError = class extends Error { 27 | constructor(body) { 28 | super(body.message); 29 | for (const k of Object.keys(body)) { 30 | this[k] = body[k]; 31 | } 32 | } 33 | }; 34 | 35 | /** 36 | * Unathorized 37 | * @extends Error 38 | * @memberof module:swagger-test 39 | * @alias module:swagger-test.Errors.Unathorized 40 | * @property {string} message 41 | */ 42 | module.exports.Errors.Unathorized = class extends Error { 43 | constructor(body) { 44 | super(body.message); 45 | for (const k of Object.keys(body)) { 46 | this[k] = body[k]; 47 | } 48 | } 49 | }; 50 | 51 | /** 52 | * Error 53 | * @extends Error 54 | * @memberof module:swagger-test 55 | * @alias module:swagger-test.Errors.Error 56 | * @property {number} code 57 | * @property {string} message 58 | */ 59 | module.exports.Errors.Error = class extends Error { 60 | constructor(body) { 61 | super(body.message); 62 | for (const k of Object.keys(body)) { 63 | this[k] = body[k]; 64 | } 65 | } 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /samples/nils.yml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | info: 3 | title: nil-test 4 | description: Testing Swagger Codegen 5 | version: 9.0.0 6 | x-npm-package: nil-test 7 | basePath: /v1 8 | schemes: 9 | - http 10 | produces: 11 | - application/json 12 | consumes: 13 | - application/json 14 | responses: 15 | BadRequest: 16 | description: "Bad Request" 17 | schema: 18 | $ref: "#/definitions/BadRequest" 19 | InternalError: 20 | description: "Internal Error" 21 | schema: 22 | $ref: "#/definitions/InternalError" 23 | 24 | paths: 25 | /check/{id}: 26 | post: 27 | operationId: nilCheck 28 | description: Nil check tests 29 | parameters: 30 | - name: id 31 | in: path 32 | type: string 33 | required: true 34 | - name: query 35 | in: query 36 | type: string 37 | - name: header 38 | in: header 39 | type: string 40 | - name: array 41 | in: query 42 | type: array 43 | items: 44 | type: string 45 | - name: body 46 | in: body 47 | schema: 48 | $ref: "#/definitions/NilFields" 49 | responses: 50 | 200: 51 | description: "Success" 52 | 53 | definitions: 54 | NilFields: 55 | type: object 56 | properties: 57 | id: 58 | type: string 59 | optional: 60 | type: string 61 | x-nullable: true 62 | 63 | BadRequest: 64 | type: object 65 | properties: 66 | message: 67 | type: string 68 | 69 | InternalError: 70 | type: object 71 | properties: 72 | message: 73 | type: string 74 | 75 | # TODO: simpler types??? (additional properties, arrays, direct definitions...) 76 | -------------------------------------------------------------------------------- /samples/test/deprecated_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "net/http/httptest" 7 | "testing" 8 | 9 | "github.com/Clever/wag/samples/gen-go-deprecated/models/v9" 10 | "github.com/Clever/wag/samples/v9/gen-go-deprecated/server" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | type DeprecatedController struct{} 16 | 17 | func (c *DeprecatedController) Health(ctx context.Context, i *models.HealthInput) error { 18 | return nil 19 | } 20 | 21 | func TestRawHttp(t *testing.T) { 22 | // This method isn't in the client, but we should still be able to hit it with raw-http 23 | // for backwards compatability 24 | s := server.New(&DeprecatedController{}, "") 25 | testServer := httptest.NewServer(s.Handler) 26 | 27 | // With invalid params 28 | resp, err := http.Get(testServer.URL + "/v1/health") 29 | assert.NoError(t, err) 30 | assert.Equal(t, 400, resp.StatusCode) 31 | 32 | // With valid params 33 | resp, err = http.Get(testServer.URL + "/v1/health?section=1") 34 | assert.NoError(t, err) 35 | assert.Equal(t, 200, resp.StatusCode) 36 | } 37 | -------------------------------------------------------------------------------- /samples/test/errors_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "net/http/httptest" 7 | "testing" 8 | 9 | "github.com/Clever/wag/samples/gen-go-errors/client/v9" 10 | "github.com/Clever/wag/samples/gen-go-errors/models/v9" 11 | "github.com/Clever/wag/samples/v9/gen-go-errors/server" 12 | 13 | "github.com/stretchr/testify/assert" 14 | "github.com/stretchr/testify/require" 15 | ) 16 | 17 | type ErrorsController struct{} 18 | 19 | func (e *ErrorsController) GetBook(ctx context.Context, i *models.GetBookInput) error { 20 | if i.ID == 404 { 21 | return models.NotFound{} 22 | } 23 | return nil 24 | } 25 | 26 | func TestGlobal404(t *testing.T) { 27 | s := server.New(&ErrorsController{}, "") 28 | testServer := httptest.NewServer(s.Handler) 29 | c := client.New(testServer.URL, wcl, &http.DefaultTransport) 30 | 31 | err := c.GetBook(context.Background(), &models.GetBookInput{ID: 404}) 32 | require.Error(t, err) 33 | assert.IsType(t, &models.NotFound{}, err) 34 | } 35 | 36 | func TestOverridenBadRequest(t *testing.T) { 37 | s := server.New(&ErrorsController{}, "") 38 | testServer := httptest.NewServer(s.Handler) 39 | c := client.New(testServer.URL, wcl, &http.DefaultTransport) 40 | 41 | err := c.GetBook(context.Background(), &models.GetBookInput{ID: 50000}) 42 | require.Error(t, err) 43 | assert.IsType(t, &models.ExtendedError{}, err) 44 | } 45 | -------------------------------------------------------------------------------- /samples/test/js/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | "stage-3" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /samples/test/js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wag-test-js", 3 | "version": "0.1.0", 4 | "description": "Tests the generated wag JS client", 5 | "dependencies": { 6 | "swagger-test": "../../gen-js" 7 | }, 8 | "devDependencies": { 9 | "@types/mocha": "^10.0.6", 10 | "@types/node": "^18.19.31", 11 | "hystrixjs": "^0.2.0", 12 | "assert": "^2.1.0", 13 | "express": "^4.19.2", 14 | "nock": "^13.5.4", 15 | "ts-node": "^10.9.2", 16 | "typescript": "^5.4.5", 17 | "mocha": "^3.1.2" 18 | }, 19 | "scripts": { 20 | "test": "mocha --require ts-node/register *.{ts,js}" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /samples/test/js/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "noImplicitAny": false 6 | }, 7 | "exclude": [ 8 | "node_modules", "public" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /server/gendb/dynamodb-local.sh.tmpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | jar=/tmp/DynamoDBLocal.jar 6 | 7 | # download the dynamo jar if necessary 8 | if [ ! -e "$jar" ] 9 | then 10 | if [ `uname` = "Darwin" ] ; then 11 | # this will prompt for java to be installed if necessary 12 | java -version 13 | else 14 | sudo apt-get update && sudo apt-get install -y default-jre 15 | fi 16 | echo "Downloading dynamodb-local..." 17 | curl -L -k --url https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -o /tmp/dynamodb_local_latest.tar.gz 18 | tar -zxvf /tmp/dynamodb_local_latest.tar.gz -C /tmp/ 19 | fi 20 | 21 | exec java -jar "$jar" -sharedDb -port 8002 22 | -------------------------------------------------------------------------------- /swagger/file.go: -------------------------------------------------------------------------------- 1 | package swagger 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | 8 | "github.com/go-openapi/spec" 9 | ) 10 | 11 | // WriteToFile writes the swagger spec to a temporary file. It returns 12 | // the name of the created file. 13 | func WriteToFile(s *spec.Swagger) (string, error) { 14 | bytes, err := json.Marshal(s) 15 | if err != nil { 16 | return "", fmt.Errorf("internal error: wag patch type marshal failure: %s", err) 17 | } 18 | tmpfile, err := ioutil.TempFile("", "example") 19 | if err != nil { 20 | return "", err 21 | } 22 | 23 | if _, err := tmpfile.Write(bytes); err != nil { 24 | return "", err 25 | } 26 | return tmpfile.Name(), nil 27 | } 28 | -------------------------------------------------------------------------------- /swagger/formats.go: -------------------------------------------------------------------------------- 1 | package swagger 2 | 3 | import ( 4 | "encoding/hex" 5 | 6 | "github.com/go-openapi/strfmt" 7 | ) 8 | 9 | // InitCustomFormats adds wag's custom formats to the global go-openapi/strfmt Default registry. 10 | func InitCustomFormats() { 11 | m := mongoID("") 12 | strfmt.Default.Add("mongo-id", &m, isMongoID) 13 | } 14 | 15 | func isMongoID(s string) bool { 16 | if len(s) != 24 { 17 | return false 18 | } 19 | _, err := hex.DecodeString(s) 20 | return err == nil 21 | } 22 | 23 | type mongoID string 24 | 25 | // MarshalText turns this instance into text 26 | func (e mongoID) MarshalText() ([]byte, error) { 27 | return []byte(string(e)), nil 28 | } 29 | 30 | // UnmarshalText hydrates this instance from text 31 | func (e *mongoID) UnmarshalText(data []byte) error { // validation is performed later on 32 | *e = mongoID(string(data)) 33 | return nil 34 | } 35 | 36 | // String representation of the Mongo ID. 37 | func (e mongoID) String() string { 38 | return string(e) 39 | } 40 | -------------------------------------------------------------------------------- /swagger/testyml/3xxresponse.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/BadRequest" 6 | InternalError: 7 | description: "Internal Error" 8 | schema: 9 | $ref: "#/definitions/InternalError" 10 | 11 | paths: 12 | /path: 13 | get: 14 | operationId: op 15 | responses: 16 | 300: 17 | description: "Success1" 18 | 19 | definitions: 20 | InternalError: 21 | type: object 22 | properties: 23 | message: 24 | type: string 25 | 26 | BadRequest: 27 | type: object 28 | properties: 29 | message: 30 | type: string 31 | -------------------------------------------------------------------------------- /swagger/testyml/badref.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/BadRef" 6 | -------------------------------------------------------------------------------- /swagger/testyml/defaults.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/BadRequest" 6 | InternalError: 7 | description: "Internal Error" 8 | schema: 9 | $ref: "#/definitions/InternalError" 10 | 11 | paths: 12 | /path: 13 | get: 14 | operationId: op 15 | responses: 16 | 404: 17 | description: "Other response" 18 | schema: 19 | $ref: "#/definitions/Error" 20 | 21 | definitions: 22 | Error: 23 | type: object 24 | properties: 25 | message: 26 | type: string 27 | 28 | InternalError: 29 | type: object 30 | properties: 31 | message: 32 | type: string 33 | 34 | BadRequest: 35 | type: object 36 | properties: 37 | message: 38 | type: string 39 | -------------------------------------------------------------------------------- /swagger/testyml/missinginternal.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/Test" 6 | 7 | definitions: 8 | Test: 9 | type: object 10 | properties: 11 | message: 12 | type: string 13 | -------------------------------------------------------------------------------- /swagger/testyml/missingmessage.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/Test" 6 | 7 | definitions: 8 | Test: 9 | type: object 10 | properties: 11 | name: 12 | type: string 13 | -------------------------------------------------------------------------------- /swagger/testyml/multisuccess.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/BadRequest" 6 | InternalError: 7 | description: "Internal Error" 8 | schema: 9 | $ref: "#/definitions/InternalError" 10 | 11 | paths: 12 | /path: 13 | get: 14 | operationId: op 15 | responses: 16 | 200: 17 | description: "Success1" 18 | schema: 19 | $ref: "#/definitions/SuccessType" 20 | 204: 21 | description: "Success2" 22 | 23 | definitions: 24 | 25 | SuccessType: 26 | type: object 27 | properties: 28 | id: 29 | type: string 30 | 31 | InternalError: 32 | type: object 33 | properties: 34 | message: 35 | type: string 36 | 37 | BadRequest: 38 | type: object 39 | properties: 40 | message: 41 | type: string 42 | -------------------------------------------------------------------------------- /swagger/testyml/override.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/Error" 6 | InternalError: 7 | description: "Internal Error" 8 | schema: 9 | $ref: "#/definitions/Error" 10 | 11 | paths: 12 | /path: 13 | get: 14 | operationId: op 15 | responses: 16 | 400: 17 | description: "Override" 18 | schema: 19 | $ref: "#/definitions/ExtendedError" 20 | 21 | definitions: 22 | Error: 23 | type: object 24 | properties: 25 | message: 26 | type: string 27 | 28 | ExtendedError: 29 | type: object 30 | properties: 31 | message: 32 | type: string 33 | extendedField: 34 | type: string 35 | -------------------------------------------------------------------------------- /swagger/testyml/requiredfield.yml: -------------------------------------------------------------------------------- 1 | responses: 2 | BadRequest: 3 | description: "Bad Request" 4 | schema: 5 | $ref: "#/definitions/Test" 6 | 7 | definitions: 8 | Test: 9 | type: object 10 | properties: 11 | message: 12 | type: string 13 | required: 14 | - message 15 | -------------------------------------------------------------------------------- /templates/templates.go: -------------------------------------------------------------------------------- 1 | package templates 2 | 3 | import ( 4 | "bytes" 5 | "text/template" 6 | ) 7 | 8 | // WriteTemplate takes in the template and the definition of its variables 9 | // and returns a filled-out template. 10 | func WriteTemplate(templateStr string, templateStruct interface{}) (string, error) { 11 | 12 | tmpl, err := template.New("test").Parse(templateStr) 13 | if err != nil { 14 | return "", err 15 | } 16 | 17 | var tmpBuf bytes.Buffer 18 | err = tmpl.Execute(&tmpBuf, templateStruct) 19 | if err != nil { 20 | return "", err 21 | } 22 | return tmpBuf.String(), nil 23 | } 24 | -------------------------------------------------------------------------------- /tracing/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Clever/wag/tracing 2 | 3 | go 1.24.0 4 | 5 | require ( 6 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 7 | go.opentelemetry.io/otel v1.35.0 8 | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 9 | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 10 | go.opentelemetry.io/otel/sdk v1.35.0 11 | go.opentelemetry.io/otel/trace v1.35.0 12 | ) 13 | 14 | require ( 15 | github.com/cenkalti/backoff/v4 v4.3.0 // indirect 16 | github.com/felixge/httpsnoop v1.0.4 // indirect 17 | github.com/go-logr/logr v1.4.2 // indirect 18 | github.com/go-logr/stdr v1.2.2 // indirect 19 | github.com/google/uuid v1.6.0 // indirect 20 | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect 21 | go.opentelemetry.io/auto/sdk v1.1.0 // indirect 22 | go.opentelemetry.io/otel/metric v1.35.0 // indirect 23 | go.opentelemetry.io/proto/otlp v1.5.0 // indirect 24 | golang.org/x/net v0.35.0 // indirect 25 | golang.org/x/sys v0.30.0 // indirect 26 | golang.org/x/text v0.22.0 // indirect 27 | google.golang.org/genproto v0.0.0-20220808204814-fd01256a5276 // indirect 28 | google.golang.org/grpc v1.71.0 // indirect 29 | google.golang.org/protobuf v1.36.5 // indirect 30 | ) 31 | --------------------------------------------------------------------------------