Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property object generation #68

Open
aygalinc opened this issue Nov 13, 2019 · 4 comments
Open

Property object generation #68

aygalinc opened this issue Nov 13, 2019 · 4 comments

Comments

@aygalinc
Copy link

I have the following schema :

CommonNetworkType:
      description: All the network types available
      type: string
      enum:
        - electrical
        - modbus-sl
    CommonNetwork:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/DefaultId'
        type:
          $ref: '#/components/schemas/CommonNetworkType'
        name:
          type: string
          description: The name of the network
          example: "My beautiful network name"
        isEnabled:
          type: boolean
          example: true
        numberOfNodes:
          type: integer
          description: "Specify the number of nodes that this network has"
          example: 12
        healthState:
          $ref: '#/components/schemas/HealthState'
CommunicationNetwork:
      oneOf:
        - $ref: '#/components/schemas/ZigbeeCommunicationNetwork'
        - $ref: '#/components/schemas/ModbusSLCommunicationNetwork'
      discriminator:
        propertyName: type
 ModbusSLCommunicationNetwork:
      allOf:
        - $ref: '#/components/schemas/CommonNetwork'
        - type: object
          properties:
            type:
              example: "modbus-sl"
            properties:
              type: object
              properties:
                baudRate:
                  type: integer
                  enum: [1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200]
                parity:
                  type: string
                  enum: ["none", "odd", "even"]
                numberOfStopBits:
                  type: string
                  enum: ["0", "1", "2"]
                frameDelay:
                  type: integer
                  example: 20
                silentinterval:
                  type: integer
                  example: 30

The ModbusSLCommunicationNetwork generation is :

public class ModbusSLCommunicationNetwork {
  private String id;
  private Object type;
  private String name;
  private Boolean isEnabled;
  private Integer numberOfNodes;
  private String healthState;
  private JsonObject properties;
....

I have hope that the properties filed will be more typed than a JsonObject.

Regards,

@AbriTj
Copy link

AbriTj commented Feb 18, 2020

Hi,

This seems to have been working on an older version if I am not mistaken. I am regenerating the model classes for a project from last year and I ran into this issue.

I have rolled back a couple of versions but I have not been able to find the version that generated model classes for property objects.

Can someone point me in the right direction? Alternatively if this is a simple fix then I would not mind making it myself if some guidance can be provided.

Kind regards,

@pmlopes
Copy link
Owner

pmlopes commented Feb 19, 2020

Maybe @slinkydeveloper can help as he knows best that code.

@AbriTj
Copy link

AbriTj commented Feb 20, 2020

Hi,

I have found a workaround. Basically inline objects don't work at the moment but you can still use $ref with a named scehma. e.g. the above section:

type: object
properties:
  baudRate:
    type: integer
    enum: [1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200]
  parity:
    type: string
    enum: ["none", "odd", "even"]
  numberOfStopBits:
    type: string
    enum: ["0", "1", "2"]
  frameDelay:
    type: integer
    example: 20
  silentinterval:
    type: integer
    example: 30

Would be a SerialNetwork schema resulting in:

ModbusSLCommunicationNetwork:
      allOf:
        - $ref: '#/components/schemas/CommonNetwork'
        - $ref: '#/components/schemas/SerialNetwork '

I am not sure what this does:

        - type: object
          properties:
            type:
              example: "modbus-sl"
            properties:

But it seems to incorrect.

I hope this helps.

Kind regards,

@AbriTj
Copy link

AbriTj commented Feb 20, 2020

On a related note, arrays become JsonArrays instead of the List types that used to be created.

@slinkydeveloper slinkydeveloper removed their assignment Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants