Java spring boot generator inheritance #1079
-
| Is there a way to make inheritance, using the Java spring boot generator with a class that is not generated using the generator ? I have a template like this (created for tests from the default template): asyncapi: '2.0.0'
info:
  title: Streetlights API
  version: '1.0.0'
  description: |
    The Smartylighting Streetlights API allows you
    to remotely manage the city lights.
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0'
servers:
  production:
    url: kafka.bootstrap:{port} ## replace with redis server
    protocol: kafka
    variables:
      port:
        default: '9092'
        enum:
          - '9092'
          - '9093'
channels:
  event.lighting.measured:
    publish:
      bindings:
        kafka:
          groupId: my-group
      operationId: ResortSAEWorkerEvent
      message:
        $ref: '#/components/messages/ResortSAEWorkerEvent'
components:
  messages:
    ResortSAEWorkerEvent:
      summary: Inform about environmental lighting conditions for a particular streetlight.
      payload:
        $ref: "#/components/schemas/ResortSAEWorkerEvent"
      x-extends: Event
  schemas:
    ResortSAEWorkerEvent:
      type: object
      properties:
        correlationId:
          type: string
          description: Unique identifier for the correlation of the event.
        eventAt:
          type: string
          format: date-time
          description: Date and time when the event was generated.
        eventType:
          type: string
          description: Type of the event.
        provider:
          type: string
          description: Name of the provider that generated the event.
        data:
          type: object
          description: The event's payload.My objective is to extend the model ResortSAEWorkerEvent to use Event. I tried to do  Do you have any ideas ? Feel free to ask if you need more datas or explainations 👍 | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| In Spring Boot, if you want to use inheritance with classes generated by a generator like the one you've provided, you'll typically have to manually create the class that you want to extend, in this case, the  1.You need to manually create a Java class named  
 For example: Event.java ResortSAEWorkerEvent.java } | 
Beta Was this translation helpful? Give feedback.
In Spring Boot, if you want to use inheritance with classes generated by a generator like the one you've provided, you'll typically have to manually create the class that you want to extend, in this case, the
Eventclass.1.You need to manually create a Java class named
Eventthat "ResortSAEWorkerEvent" can extend. This class should contain the properties and methods that you want to inherit.Once you have created the
Eventclass, you can extend it in yourResortSAEWorkerEventclass.For example:
Event.java
public class Event {
// Properties and methods that you want to inherit
}
ResortSAEWorkerEvent.java
public class ResortSAEWorkerEvent extends …