Skip to content

Commit e5132a9

Browse files
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: ![Generics in use](./images/2.1_generics_graph.svg) * 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

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 changed

CHANGELOG.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

changelog/CHANGELOG.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Gleece Changelog
2+
3+
## Gleece v2.1.0
4+
5+
### Summary
6+
7+
*Gleece* 2.1 brings in concrete support for type aliases, map input/outputs and an overhauled type resolution system.
8+
9+
### Features
10+
11+
* Support for type aliasing.</br>
12+
Previously, alias support was limited and resulted in the aliased type effectively wiping the alias itself.
13+
14+
Both declared and assigned aliases are valid:
15+
16+
```go
17+
// A unique ID
18+
type Id string `validate:"regex=^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"`
19+
20+
// A unique ID
21+
type Id = string `validate:"regex=^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"`
22+
```
23+
</br>
24+
These aliases will be translated into an equivalent OpenAPI model:
25+
26+
```yaml
27+
Id:
28+
type: "string"
29+
format: "^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$"
30+
description: "A unique ID"
31+
```
32+
</br>
33+
34+
* Full support for `map`.</br>
35+
Previously, non-primitive maps like `map[string]something.Something` would not resolve correctly, resulting errors.
36+
37+
38+
* Infrastructure-level support for generics</br>
39+
Generics support represent *Gleece*'s next major milestone.
40+
41+
This change includes the necessary infrastructure.
42+
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`)
43+
44+
Below you can see a graphical dump of a controller with generics in use:
45+
46+
![Generics in use](./images/2.1_generics_graph.svg)
47+
48+
49+
* Added an configuration option to disable failure after encountering issues during package loads.
50+
51+
To use this option, create a `failOnAnyPackageLoadError` (`boolean`) field under the `commonConfig` section of your `Gleece Config` file, e.g.:
52+
53+
```json
54+
{
55+
"commonConfig": {
56+
"failOnAnyPackageLoadError": false,
57+
"controllerGlobs": [
58+
"./*.go",
59+
"./**/*.go"
60+
]
61+
},
62+
...
63+
...
64+
...
65+
}
66+
```
67+
68+
For some complex environments, specifically those using generated code, there sometimes is a need to ignore package load errors.
69+
70+
A typical use case is when the project has controllers and generated code in the same directory hierarchy with no discernable naming patterns.
71+
72+
*Gleece* may attempt to load the yet-to-be-generated code and fail.
73+
74+
This configuration option is an 'escape hatch' for these cases.
75+
76+
### Enhancements
77+
78+
* Overhauled type resolution flows.
79+
80+
*Gleece* now has a set of composable visitors, each tailored for a specific part of the AST.
81+
82+
* Added a global `ApiValidator` as the entry point to the HIR validation subsystem.</br>
83+
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`
84+
85+
* Added an explicit visitor error when using interfaces in general and `interface{}` in particular
86+
87+
* Added a validation error when passing arrays via inputs that do not accept them (i.e., a URL parameter)
88+
89+
90+
### Bugfixes
91+
92+
* Fixed array/slice support. Previously resulted in broken generated code
93+
94+
* Fixed cases where model fields were named after the type rather than the field name or JSON tag
95+
96+
* Fixed an issue where `any` yielded an `object` schema entity rather than a 'map-like' one, i.e.,
97+
```json
98+
"someField": {
99+
"additionalProperties": {
100+
"type": "object"
101+
},
102+
"type": "object"
103+
}
104+
```
105+
106+
------------------
107+
108+
## Gleece v2.0.0
109+
110+
### Summary
111+
112+
*Gleece* 2 is a major milestone that includes a complete overhaul of the internal code analysis and validation facilities
113+
as well as a multitude of small bug fixes.
114+
115+
These changes aim drastically improve performance and allow us to better expand and maintain the project and provide the groundwork for powerful and unique features down the road like live OAS preview, LSP support and more.
116+
117+
For more information, please see the [architecture](https://docs.gleece.dev/docs/about/architecture) section of our documentation.
118+
119+
### Features
120+
121+
* Added a rich, LSP oriented diagnostics system. Issues will be reporter with far greater detail and clarity
122+
123+
* Added many validation previously available only via the IDE extension
124+
125+
* Added facilities necessary to generate full project dependency graphs (`SymbolGraph.ToDot`)
126+
127+
* Created a `GleecePipeline` to orchestrate execution and lifecycle.
128+
This allows re-using caches and previous analysis results to expedite subsequent operations.
129+
130+
* Added support for `byte` and `time.Time` fields in returned structs
131+
132+
### Enhancements
133+
134+
* Improved analysis speed by up to 50% via code optimization and introduction of package, file and node caches
135+
136+
* Adjusted most processes to yield sorted results for more consistent builds results
137+
138+
* Reduced import clutter in generated route files
139+
140+
* Re-structured the project to provide a much clearer separation of concerns and allow for easier maintenance
141+
142+
* Improved test coverage
143+
144+
### Bugfixes
145+
* Fixed several cases of panic due to mis-configuration or invalid commands
146+
147+
* Fixed cases where documentation was not properly siphoned from some types of entities
148+
149+
* Fixed several issues with complex, nested type layers (*e.g*.map[string][][]int) resolution
150+
151+
* Fixed several issues with complex type resolution
152+
153+
* Fixed several issues with import detection resulting in resolution failures
154+
155+
* Fixed an issue that could cause type information to be emitted with incorrect `PkgPath`
156+
157+
* Fix custom error causing OpenAPI 3.1 generation to fail
158+
159+
* Fix Query parameter with array of primitive types not being generated correctly

0 commit comments

Comments
 (0)