37 Commits

Author SHA1 Message Date
Dragos Vingarzan
c2884b7b1a
[BUG][Go-server] attempt to fix the controller-api mustache template for a nullable bodyParam (#20478)
* go-server: attempt  to fix the controller-api mustache template for a nullable bodyParam

* added to petstore an example to trigger the issue which this PR fixes
2025-02-19 17:09:32 +08:00
Dragos Vingarzan
dcf472a034
ISSUE: #17373 [BUG] [Go-server] invalid composite literal type string (#20467)
* modules/openapi-generator/src/main/resources/go-server: alternative initialization of variable, to avoid extra checks and custom code

* propagated changes to samples
2025-01-15 16:36:33 +08:00
Beppe Catanese
243f501aef
[GO] Go Server: preserve order of the routes as defined in the OpenAPI file (#19550)
* Add skipSortingOperations configuration option

* Skip sorting operations for go-server

* Add test verifyOrder

* Regenerate samples
2024-09-16 16:52:01 +08:00
Ween Jiann
8f6a2860bf
[go-server] Fix: error handling and linting (#18550)
* Update error.go and fix lint

* Regen

* Fix incorrect change

* Fix handler issue

* Regenerate
2024-05-08 00:06:45 +08:00
keyjh2
228b47a953
[go-server] Fix: missing sample changes from previous commit (#18546) (#18588) 2024-05-07 11:27:19 +08:00
Ween Jiann
cefbf62060
[go-server] Fix: missing quotes for string default value (#18546)
* Update controller mustache

* Add tests to openapi doc

* Regen
2024-05-06 14:17:44 +08:00
rledisez
230e8ce887
[go-server] add field name in parsing error messages (#18533)
Currently when a parsing rule of a field is not respected (eg: min/max
value, required, ...), the api only returns an  error message without
providing the field name to help the user to fix the request. This commit
add the field name to the error message to help the user of the API.
2024-05-01 19:28:51 +08:00
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
Ween Jiann
bf4c98a82a
[go-server] Add ability to handle nullable query param (#17321)
* Update

* Regen
2023-12-21 19:13:05 +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
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
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
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
Aliaksei Zhuk
9c3d4ef2a6
Parse integer array query parameters. Fix typos (#11105) 2022-01-04 17:55:18 +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
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
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
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
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
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
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
Jesse Michael
0abb910dbc [go-server] Enhance Go API server with interfaces router binding and services (#4038)
* Enhance go api server with interfaces router binding and services

Enhance the default go api server generation to define interfaces for an API's routes and services. Handle an endpoint's http binding in the generated router and the skeleton for the service logic in an API service.

* Include interface documentation in Go Server generation.
2019-10-19 23:32:52 +08:00
Ben Wells
c51986d657 Go server clean up (#328) 2018-06-18 01:09:48 +08:00
William Cheng
0dbb6dcaa6
Update Go generators' default value (#362)
* udpate go client default value

* update go generators' default value
2018-05-08 10:16:38 +08:00
antihax
72abb20f2e [Go] Fix operation files clobbering model files. [2.4.0] (#7337)
* Prevent operation files clobbering model files.

* Update Tests
2018-01-14 17:00:17 +08:00