Giter Club home page Giter Club logo

Comments (8)

MikeRalphson avatar MikeRalphson commented on August 22, 2024 2

@timburks or colleagues?

from generator.

vearutop avatar vearutop commented on August 22, 2024 2

FYI, there is a tool that can generate Go and PHP code for message models.

json-cli gen-go "https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0-rc1/examples/1.2.0/streetlights.yml" \
    --ptr-in-schema "#/components/messages/lightMeasured/payload" "#/components/messages/turnOnOff/payload" \
    --def-ptr "#/components/schemas" \
    --package-name message \
    --output ./entities.go
// Code generated by github.com/swaggest/json-cli v1.6.3, DO NOT EDIT.

// Package message contains JSON mapping structures.
package message

import (
        "fmt"
        "time"
)

// LightMeasuredPayload structure is generated from "#/components/schemas/lightMeasuredPayload".
type LightMeasuredPayload struct {
        Lumens int64      `json:"lumens,omitempty"` // Light intensity measured in lumens.
        SentAt *time.Time `json:"sentAt,omitempty"` // Date and time when the message was sent.
}

// TurnOnOffPayload structure is generated from "#/components/schemas/turnOnOffPayload".
type TurnOnOffPayload struct {
        Command TurnOnOffPayloadCommand `json:"command,omitempty"` // Whether to turn on or off the light.
        SentAt  *time.Time              `json:"sentAt,omitempty"`  // Date and time when the message was sent.
}

// TurnOnOffPayloadCommand is an enum type.
type TurnOnOffPayloadCommand string

// TurnOnOffPayloadCommand values enumeration.
const (
        TurnOnOffPayloadCommandOn = TurnOnOffPayloadCommand("on")
        TurnOnOffPayloadCommandOff = TurnOnOffPayloadCommand("off")
)

// MarshalJSON encodes JSON.
func (i TurnOnOffPayloadCommand) MarshalJSON() ([]byte, error) {
        switch i {
        case TurnOnOffPayloadCommandOn:
        case TurnOnOffPayloadCommandOff:

        default:
                return nil, fmt.Errorf("unexpected TurnOnOffPayloadCommand value: %v", i)
        }

        return json.Marshal(string(i))
}

// UnmarshalJSON decodes JSON.
func (i *TurnOnOffPayloadCommand) UnmarshalJSON(data []byte) error {
        var ii string
        err := json.Unmarshal(data, &ii)
        if err != nil {
                return err
        }
        v := TurnOnOffPayloadCommand(ii)
        switch v {
        case TurnOnOffPayloadCommandOn:
        case TurnOnOffPayloadCommandOff:

        default:
                return fmt.Errorf("unexpected TurnOnOffPayloadCommand value: %v", v)
        }

        *i = v
        return nil
}

from generator.

vgarvardt avatar vgarvardt commented on August 22, 2024

I'm working on one now but I definately need some help. At the moment have simpe strcut generation for messages but need to add some tests.

from generator.

fmvilas avatar fmvilas commented on August 22, 2024

Hey @vgarvardt! I'm planning to work on one too. Join the Slack channel and let's work together on this.

from generator.

fmvilas avatar fmvilas commented on August 22, 2024

Lovely! Thanks for sharing!

from generator.

derberg avatar derberg commented on August 22, 2024

@vgarvardt hey man, are you still in the topic? I don't think that @fmvilas is still involved in writing a template but seems more people are interested #209 so would be good to join forces maybe?

from generator.

github-actions avatar github-actions commented on August 22, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

from generator.

derberg avatar derberg commented on August 22, 2024

Closing this one
Discussions should be under one issue #209

from generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.