71 Commits

Author SHA1 Message Date
William Cheng
494d74ab82
remove duplicated (#18320) 2024-04-07 22:25:03 +08:00
Viswajith Venugopal
650e119f22
Update go-server template to include the conventional generated code line (#18304)
* Update go-server template to include the conventional generated code line

Follow the convention from https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source.

The generated go client code already follows this: f357be480e/modules/openapi-generator/src/main/resources/go/partial_header.mustache (L18)

* gen files

* Move to top
2024-04-07 21:23:24 +08:00
Gonzalo Gomez
af71460c86
[Go-Server] Use ParseQuery For Parsing Query Parameters (#17585)
* Uses ParseQuery to check for malform paramater value pairs.
Runs ./mvnw clean package, ./bin/generate-samples.sh ./bin/configs/*.yaml, and ./bin/utils/export_docs_generators.sh.

* Adds missing import

* Only import url if hasQueryParams.

* Adds helper function to wrap url.ParseQuery.

* Fixes function return signature
2024-01-15 13:43:04 +08:00
Erik Booij
90f3b24edc
fix(go-server): ensure original filename can be deduced from tmp file (#17416) 2024-01-10 02:00:44 +08:00
Ween Jiann
bf4c98a82a
[go-server] Add ability to handle nullable query param (#17321)
* Update

* Regen
2023-12-21 19:13:05 +08:00
Ween Jiann
b7f31ddda4
Regenerate (#17389) 2023-12-13 22:17:15 +08:00
Ian Cubbon
c9f7af752f
Verify Path params that fall into the string bucket are supplied (#17032) 2023-11-13 11:02:33 +08:00
Ian Cubbon
2f655f1a9c
Time parameters in the path resulted in code that would not compile (#17021)
This is probably a pretty rare case as it just seems weird to have a time
path parameter, but it's good to fix.
2023-11-13 10:01:32 +08:00
Ian Cubbon
291ce353ce
[Go][Server] FormParams - Generic Array Type Handling (#17001)
* If a form param is an array and isn't caught in the previous checks, treat it as a slice of strings.

* Add an example of a FormParam that is an array
2023-11-08 14:09:12 +08:00
Ian Cubbon
677b6e64c1
If parsing a boolean fails, return a ParsingError instead of a straight 500 (#16910)
Add an example endpoint that covers Required, Default, and Not Required cases
2023-10-28 20:32:04 +08:00
Ian Cubbon
bf9fae641e
[Go-Server] Add support for DateTime Query Parameters (#16749)
* Add support for DateTime objects in the Path, Query Params, and as a List

* Fix indentation

* Add an exaple that has dateTimes
Move the date parsing into a common util in the routers.go file.

* Fix compilation issue and regen

* Use the `RequiredError` to handle this case

* Only split on a "," and not an extra 'space' after the ",".
2023-10-22 21:07:13 +08:00
Ian Cubbon
e0738a6e42
[Go-Server] Support for an endpoint returning a file to the client - #15206 (#16748)
* Support for an endpoint returning a file to a client.

* Spaces to tabs conversion

* Add an example endpoint for download a file

* Regenerate after merging main
2023-10-17 11:42:27 +08:00
Ian Cubbon
1dd9590064
[Go-server] - Support for Enums in the Path and Query (#16781)
* Add support for Enums to be part of the Path and Query
Supports optional Query Enums and Lists of Enums as well
Add an example endpoint that covers the added scenarios
Added an import mapping for the GoServerCodegen for "fmt"
    when a model is an enum.
Expanded the Enum Model for the Go Server to have validation.
    Copied this logic from the Go Client Enum Model.

* Fix identation of examples

* Pre-allocate the capacity of the slice of Enums to be
the correct size.

* Formatting and updated examples

* Empty-Commit

* Switch to using a map to store the valid enum values

* Fixed pointer derefs missed from previous change in PR

* More fixing of pointer to not pointer

* Create a map for validation and a list of enums for messaging
2023-10-17 11:35:39 +08:00
Gonzalo Gomez
571aefa3da
io/ioutil has been deprecated. (#16822)
Uses os.CreateTemp to create temp directory.
Uses io.Copy to avoid reading file into memory.
2023-10-14 10:04:06 +08:00
William Cheng
ba367e60e8
[go-server] Add tests, minor format change (#16805)
* add tests for #16787, minor format change

* revert

* fix typo

* use pet instead of fake

* update samples
2023-10-12 19:23:02 +08:00
Ween Jiann
2b44d4ed93
[go-server] Partially reverts and fix #15185 (#16258)
* Partitally reverts #15185

* Remove unused import

* Set zero value if param is empty

* Refactor samples, add test config

* Add tests

* Clean up

* Fix test
2023-08-07 20:43:30 +08:00
William Cheng
54c8bf8733
[go-server] Add tests for boolean query parameter (#15563)
* add tests for boolean query parameter

* fix test
2023-05-18 15:39:43 +08:00
rledisez
44ad6d5eac [go-server] Support min/max/defaults for values (#15185)
* [go-server] Support min/max/defaults for values

Enforce, for the go-server, to check the minimum and maximum values
specified in the openapi description. Also apply the default if the
parameter is not passed.

Fix #14013

* Fix merge conflict

Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com>

* Improve UnmarshalJSON implementation

Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com>

* Improve default value handling for string

Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com>

* Fix suggested changes

* rework option pattern

* add imports based on types/min max values

---------

Co-authored-by: Ween Jiann <16207788+lwj5@users.noreply.github.com>
2023-05-17 01:58:28 +08:00
Ween Jiann
78bffff8f3
[Go] Update API naming to follow Golang standard pkg (1 line change) (#15331)
* Add apiNameSuffix to AbstractGoCodegen

* Regenerate files

* Update tests

* Regenerate files

* Update test files

* Regenerate for CI test

* Regenerate for CI test

* Remove some docs

* Add files back
2023-05-13 09:40:26 +08:00
William Cheng
935146d187 Merge remote-tracking branch 'origin/master' into 7.0.x 2023-04-12 17:51:47 +08:00
Ween Jiann
04441188c6
[go-server] Update dependencies and use generics (#15087)
* Update dependecies and go version

* Use generics for recurse

* Fix helpers.mustache

* Regenerate samples
2023-04-12 16:37:39 +08:00
Ween Jiann
792c49a0ce
[go-server] Change Routes type from []Route to map[string]Route (#15084)
* Change Routes to map[string]Route

* Fix linting issues

* Regenerate samples
2023-04-11 15:40:06 +08:00
Ween Jiann
8ce990d3d7
[go-server] Add ability to handle parameters of number type (#15079)
* Add ability to handle parameters of number type

* Generate samples

* Add handling for number without format

* Regenerate samples

* Fix indentation
2023-04-11 15:38:58 +08:00
William Cheng
7968349991
go server - use tabs instead of spaces (#14740) 2023-02-18 00:37:53 +08:00
Rodrigo Cebrián González
612dc4dbcb
[BUG][Go] Remove "null" body value when body is empty #13927 (#13934)
* only write reponse body if not nil

* update go samples

* golang style convention
2023-02-18 00:29:12 +08:00
Sebastian Cevallos
8540c82d30
Add handling for parsing optional bool params & regenerate samples (#14550) 2023-01-30 16:35:19 +08:00
Ian Cubbon
74073df27c
[GO][Client] Use a *os.File for the API Client when uploading and downloading (#14340)
* Change the return type of a file back to a pointer

* Change the api template to handle not double pointer-ing return types of os.File

* Fix unit tests

* Couple more unit test fixes
2023-01-16 16:51:04 +08:00
Ian Cubbon
63629ad51c
[Go] File Download Fix Return Type (#14046)
* Changes manually cherry-picked (for the most part) from https://github.com/OpenAPITools/openapi-generator/pull/12685/files

* Examples updated post changes

* Missed a change in the mustache template

* Update examples after last fix

* Missed dereference for required files

* Update unit tests

* Missed another test case update

* `f := *f` isn't quite the same as `*f, err = ...`
2022-12-06 12:21:39 +08:00
Aliaksei Zhuk
9c3d4ef2a6
Parse integer array query parameters. Fix typos (#11105) 2022-01-04 17:55:18 +08:00
Nathan Baulch
5d68bd6a03
Fix thousands of spelling typos (#10272) 2021-08-28 22:58:24 +08:00
Ween Jiann
3b8f66cd1f
[go-server] Fix: param names clash with variables, added suffix (#10243)
* Postfix "Param" to param names in controller

* Regen samples
2021-08-27 13:07:31 +08:00
William Cheng
0204bf4ae2 Squashed commit of the following:
commit c5a0d0f7394aa742fa336fff7e7c1d3049761868
Merge: 8c4991ba3ed f8ff8c87609
Author: William Cheng <wing328hk@gmail.com>
Date:   Tue Aug 17 18:28:12 2021 +0800

    Merge branch 'mustache-linting' of https://github.com/NathanBaulch/openapi-generator into NathanBaulch-mustache-linting

commit f8ff8c87609b1ca36fa26fb8474806999638195e
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Thu Aug 5 14:12:47 2021 +1000

    Reorder tags that handle missing values

commit f5d8a33709d6a3f846a9fe4520b78c3d637051d9
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Thu Aug 5 14:08:59 2021 +1000

    Use dot notation where possible

commit 493d14921e2333f3ae19ef6fc89318b7e263a80c
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Thu Aug 5 14:10:49 2021 +1000

    Remove empty tags

commit 32480dc53f48227d55531b94e307d72671373737
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Thu Aug 5 10:41:58 2021 +1000

    Remove redundant sections

commit a8edabd722c34aa094b4aeb11c22664529c3a219
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Wed Aug 4 22:02:22 2021 +1000

    Trim extra EOF new lines

commit e89bd7458e3594bf0d30e580bc9408e45b018a57
Author: Nathan Baulch <nathan.baulch@gmail.com>
Date:   Wed Aug 4 21:59:26 2021 +1000

    Trim trailing whitespace
2021-08-17 18:37:51 +08:00
Ween Jiann
11d29eb22b
[go-server] Feat: add required assertions to models (#10068)
* Add RequiredError

* Add IsZeroValue helper

* Add AssertRequired method to all models

* Add AssertRequired call for body param

* Regenerate files

* Add DisallowUnknownFields

* Regenerate samples

* Use hasRequired in model to remove unnecessary code

* Revert disallowUnknownFields

* Use isAdditionalPropertiesTrue for disallowing unknown fields

* Updated samples

* Fix indent

* Add require checks for nested slices

* Add new tests

* Regenerate samples

* Regenerate samples after merging
2021-08-07 21:29:14 +08:00
Nathan Baulch
c1c5775271
[go] More idiomatic godoc comments (#10044)
* [go] More idiomatic godoc comments

* [go] Mark deprecated fields and functions

* [go] Minor mustache readability/consistency fixes

* [go] Mark deprecated operation parameters

* [go] Deprecate a petstore component property for testing

* [go] Apply deprecated godoc in Go servers also
2021-08-03 17:11:16 +08:00
Ween Jiann
870ef3a87a
[go-server] Allow user to specify how errors are handled (#9764)
* Added error.go

* Updated controller to use error

* Fix redeclared func

* Add generated files

* Merge

* Added docs

* Remove variadic

* Regenerate files

* Updated go doc to meet standard

* Updated doc to meet go standard

* Updated
2021-07-28 17:19:47 +08:00
Max Goltzsche
2e85ccdec8
[go-server] fix addResponseHeaders tpl option typo (#9814)
According to the [documentation](https://openapi-generator.tech/docs/generators/go-server) the go-server generator should support an `addResponseHeaders` option but a template uses an `addResponseHeader` option in some places which this PR fixes.

Closes #9795

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
2021-06-21 11:46:51 +08:00
Aliaksei Zhuk
53e5986800
[Go] Parse int arrays and respect the 'required' property (#9120)
* Added int arrays parsing in parameters. Respect the 'required' property.

* Replaced spaces with tabs

* Generate samples with new spacing

* Removed unused import

* Merged with latest master
2021-04-11 23:43:53 +08:00
William Cheng
5dae270c3e
[Go][server] parse bool in query parameter (#9171)
* Add bool query in example

* Add parseBoolParameter

* test with boolean parameter

* add endpiont for testing boolean

* remove bool parameter test

Co-authored-by: Stéphane Guillemot <gmtstephane@gmail.com>
2021-04-05 16:45:38 +08:00
William Cheng
c79d056935
Allow to specify response headers (needed for redirecting clients) (#9170)
* Allow to specify response headers (needed for redirecting clients) (#8148)

Co-authored-by: Bernardo Pastorelli <13519917+randomswdev@users.noreply.github.com>

* add addResponseHeaders option

* enable addResponseHeaders

* fix comma

Co-authored-by: randomswdev <randomswdev@users.noreply.github.com>
Co-authored-by: Bernardo Pastorelli <13519917+randomswdev@users.noreply.github.com>
2021-04-05 16:27:41 +08:00
Yannick Schutz
85b2b3c2e4
Add mime/multipart missing import in go server (#8790) 2021-02-27 14:50:16 +08:00
randomswdev
d1dcdad3d5
[Go][Server] Use the correct parameter name (#8144)
* Use the correct parameter name

* Minor changes

Co-authored-by: Bernardo Pastorelli <13519917-randomswdev@users.noreply.github.com>
2020-12-20 15:32:57 +08:00
Aliaksei Zhuk
9e5610488f
[Go] Fix for 'Invalid code for files array in multipart/form-data request'… (#8103)
* Fix for 'Invalid code for files array in multipart/form-data request' (OpenAPITools#8093)

* Executed ensure-up-to-date

* Replaced spaces with tabs.
2020-12-10 18:48:45 +08:00
William Cheng
c44865279a
replace spaces with tabs (#7421) 2020-09-15 18:13:07 +08:00
Gmtstephane
4e05912ae7
[GO][SERVER] Implement response code (#7397)
* Feature(template) add response with status code generation

* Generate Samples

* update samples

Co-authored-by: William Cheng <wing328hk@gmail.com>
2020-09-14 23:14:53 +08:00
ryutah
b3b4526bf7
[go-server] Modified go-server templates to allow services to receive http request's context. (#7214)
* adds context arguments to go-server templates (#6657)

* updates go-api-server samples (#6657)
2020-08-15 00:11:44 +08:00
debugman
742b8bd650
added int32 support for go-server (#7123) 2020-08-06 17:17:07 +08:00
William Cheng
52fcdd5974
Migrate Go server samples to OAS 3 only (#6471)
* migrate go server samples to oas3

* add back pom.xml
2020-05-29 11:42:07 +08:00
William Cheng
db729be7df
[Go][Server] minor enhancement to the template (#4417)
* minor enhancement to the go server template

* update samples
2019-11-09 11:24:12 +08:00
Jesse Michael
00c6e0a64b Return Router interface from controller constructor. (#4196)
Update the go server api controller template to return the Router interface instead of the api specific router.
The Router interface type has the Routes function, which is what the generated `NewRouter` function needs. (not the api specific interface).
2019-10-22 15:27:08 +08:00
William Cheng
f43c720b08
replace 4-space with tab (#4188) 2019-10-20 00:46:25 +08:00