Skip to content

Commit

Permalink
Revert "feat: fixed data tags, description preset for Go, add goInclu…
Browse files Browse the repository at this point in the history
…deComments and goIncludeTags flags (asyncapi#2123)"

This reverts commit 8a06f1a.
  • Loading branch information
jonaslagoni committed Jan 24, 2025
1 parent 6d300f6 commit 83217e2
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 451 deletions.
19 changes: 5 additions & 14 deletions docs/languages/Go.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ There are special use-cases that each language supports; this document pertains
<!-- toc is generated with GitHub Actions do not remove toc markers -->
<!-- toc -->

- [Go](#go)
- [Generate serializer and deserializer functionality](#generate-serializer-and-deserializer-functionality)
- [To and from JSON](#to-and-from-json)
- [JSON Tags](#json-tags)
- [To and from XML](#to-and-from-xml)
- [To and from binary](#to-and-from-binary)
- [Rendering comments from description and example fields](#rendering-comments-from-description-and-example-fields)
- [Generate serializer and deserializer functionality](#generate-serializer-and-deserializer-functionality)
* [To and from JSON](#to-and-from-json)
* [To and from XML](#to-and-from-xml)
* [To and from binary](#to-and-from-binary)

<!-- tocstop -->

Expand All @@ -27,7 +24,7 @@ Here are all the supported presets and the libraries they use for converting to

#### JSON Tags

To generate go models that work correctly with JSON marshal functions we need to generate appropriate JSON `struct-tags`, use the preset `GO_COMMON_PRESET` and provide the option `addJsonTag: true` (added in CLI by default).
To generate go models that work correctly with JSON marshal functions we need to generate appropriate JSON `struct-tags`, use the preset `GO_COMMON_PRESET` and provide the option `addJsonTag: true`.

check out this [example for a live demonstration](../../examples/go-json-tags/)

Expand All @@ -36,9 +33,3 @@ Currently not supported, [let everyone know you need it](https://github.com/asyn

### To and from binary
Currently not supported, [let everyone know you need it](https://github.com/asyncapi/modelina/issues/new?assignees=&labels=enhancement&template=enhancement.md)!

## Rendering comments from description and example fields

You can use the `GO_DESCRIPTION_PRESET` to generate comments from description fields in your model.

See [this example](../../examples/generate-go-asyncapi-comments) for how this can be used.
17 changes: 0 additions & 17 deletions examples/generate-go-asyncapi-comments/README.md

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions examples/generate-go-asyncapi-comments/index.spec.ts

This file was deleted.

116 changes: 0 additions & 116 deletions examples/generate-go-asyncapi-comments/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions examples/generate-go-asyncapi-comments/package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions examples/generate-go-asyncapi-comments/package.json

This file was deleted.

9 changes: 6 additions & 3 deletions examples/generate-go-enums/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

exports[`Should be able to render Go Enums and should log expected output to console 1`] = `
Array [
"type Root struct {
"// Root represents a Root model.
type Root struct {
Cities *Cities
Options *Options
}",
Expand All @@ -11,7 +12,8 @@ Array [

exports[`Should be able to render Go Enums and should log expected output to console 2`] = `
Array [
"type Cities uint
"// Cities represents an enum of Cities.
type Cities uint
const (
CitiesLondon Cities = iota
Expand Down Expand Up @@ -39,7 +41,8 @@ var ValuesToCities = map[any]Cities{

exports[`Should be able to render Go Enums and should log expected output to console 3`] = `
Array [
"type Options uint
"// Options represents an enum of Options.
type Options uint
const (
OptionsNumber_123 Options = iota
Expand Down
3 changes: 2 additions & 1 deletion examples/generate-go-models/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

exports[`Should be able to render Go Models and should log expected output to console 1`] = `
Array [
"type Root struct {
"// Root represents a Root model.
type Root struct {
Email string
}",
]
Expand Down
9 changes: 6 additions & 3 deletions examples/go-json-tags/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

exports[`Should be able to render json-tags in struct and should log expected output to console 1`] = `
Array [
"type Root struct {
"// Root represents a Root model.
type Root struct {
Cities *Cities \`json:\\"cities,omitempty\\"\`
Options *Options \`json:\\"options,omitempty\\"\`
}",
Expand All @@ -11,7 +12,8 @@ Array [
exports[`Should be able to render json-tags in struct and should log expected output to console 2`] = `
Array [
"type Cities uint
"// Cities represents an enum of Cities.
type Cities uint
const (
CitiesLondon Cities = iota
Expand Down Expand Up @@ -52,7 +54,8 @@ func (op Cities) MarshalJSON() ([]byte, error) {
exports[`Should be able to render json-tags in struct and should log expected output to console 3`] = `
Array [
"type Options uint
"// Options represents an enum of Options.
type Options uint
const (
OptionsNumber_123 Options = iota
Expand Down
15 changes: 10 additions & 5 deletions examples/go-union-type/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

exports[`Should be able to render union types and should log expected output to console 1`] = `
Array [
"type AdditionalProperty struct {
"// AdditionalProperty represents a AdditionalProperty model.
type AdditionalProperty struct {
AdditionalPropertyOneOf_0
AdditionalPropertyOneOf_1
string
Expand All @@ -16,7 +17,8 @@ Array [

exports[`Should be able to render union types and should log expected output to console 2`] = `
Array [
"type Union struct {
"// Union represents a Union model.
type Union struct {
string
float64
ModelinaAnyType interface{}
Expand All @@ -26,7 +28,8 @@ Array [

exports[`Should be able to render union types and should log expected output to console 3`] = `
Array [
"type AdditionalPropertyOneOf_6 struct {
"// AdditionalPropertyOneOf_6 represents a AdditionalPropertyOneOf_6 model.
type AdditionalPropertyOneOf_6 struct {
string
float64
bool
Expand All @@ -42,7 +45,8 @@ Array [

exports[`Should be able to render union types and should log expected output to console 5`] = `
Array [
"type AdditionalPropertyOneOf_0 struct {
"// AdditionalPropertyOneOf_0 represents a AdditionalPropertyOneOf_0 model.
type AdditionalPropertyOneOf_0 struct {
Ref string
AdditionalProperties map[string]interface{}
}",
Expand All @@ -51,7 +55,8 @@ Array [

exports[`Should be able to render union types and should log expected output to console 6`] = `
Array [
"type AdditionalPropertyOneOf_1 struct {
"// AdditionalPropertyOneOf_1 represents a AdditionalPropertyOneOf_1 model.
type AdditionalPropertyOneOf_1 struct {
Id string
AdditionalProperties map[string]interface{}
}",
Expand Down
3 changes: 1 addition & 2 deletions modelina-cli/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/lib
/tmp
/scripts
/test/helpers/init.js
/test/fixtures/generate
/test/helpers/init.js
4 changes: 2 additions & 2 deletions modelina-cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default class Models extends ModelinaCommand {
try {
document = await readFile(file, 'utf8');
} catch {
throw new Error(`Unable to read input file content: ${file}`);
throw new Error('Unable to read input file content.');
}

const logger = {
info: (message: string) => {
this.log(message);
Expand Down
Loading

0 comments on commit 83217e2

Please sign in to comment.