6 Commits

Author SHA1 Message Date
CTerasa-ep
b847140834
[C++][Pistache] Generate API generalization interface (#15279)
* [C++][Pistache] Refactor setupSupportingFiles

Supporting files are set up in the CppPistacheServerCodegen()
constructor as well as in processOpts(). Refactor the code and extract a
method setupSupportingFiles().

* [C++][Pistache] Refactor: Simplify isQueryParam condition

Both branches of the if/else do the same steps. Refactor this out and
invert logic.

* [C++][Pistache] Refactor: Add injectImplInFilename

Both branches of the if/else if do the similar steps and are dependent
on the suffix. Make this obvious by introducing a new method
injectImplInFilename(String result, String suffix).

* [C++][Pistache] Refactor: injectImplInFilename: remove index search

We do not need the separatorChar index to inject the "Impl" string.
Simply truncate the whole string.

Also rename the parameter from 'result' to' filename'.

* CppPistacheServer: Refactor postProcessOperationsWithModels

Pull out the post-processing for a single operation, and also pull out
post-processing for parameters.

Introduce boolean expressions for supported parsing per parameter, and
consumption of JSON.

Reorder code to make locality more explicit i.e. how consumeJSON and
isParsingSupported is generated and used.

* CppPistacheServer: Refactor to use functional matching

Functional matching like anyMatch() directly state what boolean value is
 searched.

 However, the Predicates deserve to heave names themselves.

* CppPistacheServer: Add base class for Api

Looking at the generated main-api-server.cpp code it gets obvious that
the API classes are self similar with a similar interface.
Only the construction and teh initialization is called in the main()
function. Leverage this fact to create a generalization ApiBase.

Introduce ApiBase as a pure virtual base class to the concrete API
classes and declare init() as virtual.

Pull the route member into the base class.

With this change we could have a container hold all the ApiImpl
objects later and call init() on all of them using a for_each loop.

* CppPistacheServer: Use ApiBase for ApiImpl storage

Refactor the main-api-server template to use a vector for ApiImpl
storage instead of separate objects. This leverages the previously
added ApiBase generalization.

 We push all concrete ApiImpl objects into a vector and call init() on
  each of them.

* [C++][Pistache]: Update generated sample

Due to teh addition of ApiBase class update the generated sample.

* [C++][Pistache] Add comment for postProcessSingleParam

* [C++][Pistache] Rename and comment implFilenameFromApiFilename

While writing the comment, I realized that the method name could be more
precise. Thus rename injectImplInFilename to implFilenameFromApiFilename
and add comment.
2023-04-26 20:01:58 +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
sunn
b5fb92d5a8
[C++] [Pistache] Removed deprecated warnings (#3985)
* Removed deprecated warnings

* Fix typo
2019-09-29 20:12:59 +02:00
sunn
e85e1f112a
Separate exception types (#2930) 2019-05-18 11:57:23 +02:00
sunn
1fddb69960
Allow socket address reuse option (#2780) 2019-05-01 23:16:53 +02:00
sunn
e32b70d579
Allow all apis under a single endpoint to be hosted in one server (#1230) 2018-10-20 13:50:09 +02:00