Commit e5132a9
authored
V2 refactor - core (#68)
## Gleece v2.0.0-Release
### Summary
*Gleece* 2.1 brings in concrete support for type aliases, map input/outputs and an overhauled type resolution system.
### Features
* Support for type aliasing.</br>
Previously, alias support was limited and resulted in the aliased type effectively wiping the alias itself.
Both declared and assigned aliases are valid:
```go
// A unique ID
type Id string `validate:"regex=^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"`
// A unique ID
type Id = string `validate:"regex=^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"`
```
</br>
These aliases will be translated into an equivalent OpenAPI model:
```yaml
Id:
type: "string"
format: "^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"
description: "A unique ID"
```
</br>
* Full support for `map`.</br>
Previously, non-primitive maps like `map[string]something.Something` would not resolve correctly, resulting errors.
* Infrastructure-level support for generics</br>
Generics support represent *Gleece*'s next major milestone.
This change includes the necessary infrastructure.
These include expansion of the HIR to encode the one-to-many relationships between composites (e.g. `Something[string, bool, int]`) and their instantiated dependencies (e.g. `string`, `bool` and `int`)
Below you can see a graphical dump of a controller with generics in use:

* Added an configuration option to disable failure after encountering issues during package loads.
To use this option, create a `failOnAnyPackageLoadError` (`boolean`) field under the `commonConfig` section of your `Gleece Config` file, e.g.:
```json
{
"commonConfig": {
"failOnAnyPackageLoadError": false,
"controllerGlobs": [
"./*.go",
"./**/*.go"
]
},
...
...
...
}
```
For some complex environments, specifically those using generated code, there sometimes is a need to ignore package load errors.
A typical use case is when the project has controllers and generated code in the same directory hierarchy with no discernable naming patterns.
*Gleece* may attempt to load the yet-to-be-generated code and fail.
This configuration option is an 'escape hatch' for these cases.
### Enhancements
* Overhauled type resolution flows.
*Gleece* now has a set of composable visitors, each tailored for a specific part of the AST.
* Added a global `ApiValidator` as the entry point to the HIR validation subsystem.</br>
This currently includes a URL conflict detection algorithm to emit diagnostics upon route conflicts such as between `POST /a/b/c` and `POST /a/{foo}/c`
* Added an explicit visitor error when using interfaces in general and `interface{}` in particular
* Added a validation error when passing arrays via inputs that do not accept them (i.e., a URL parameter)
### Bugfixes
* Fixed array/slice support. Previously resulted in broken generated code
* Fixed cases where model fields were named after the type rather than the field name or JSON tag
* Fixed an issue where `any` yielded an `object` schema entity rather than a 'map-like' one, i.e.,
```json
"someField": {
"additionalProperties": {
"type": "object"
},
"type": "object"
}
```1 parent 2d648b3 commit e5132a9
File tree
130 files changed
+10757
-2569
lines changed- changelog
- images
- common
- core
- annotations
- arbitrators
- caching
- metadata
- typeref
- pipeline
- validators
- diagnostics
- paths
- visitors
- providers
- definitions
- gast
- graphs
- dot
- symboldg
- test
- alias
- context
- diagnostics
- errorhandling
- generics
- graph
- sanity
- specials
- units
- arbitrators
- cache
- commons
- graphs
- dot
- symbol
- metadata
- typeref
- utils
- matchers
- visitors
- controller
- orchestrator
- route
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
130 files changed
+10757
-2569
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
0 commit comments