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

Imporve api response schema #146

Closed
gaohoward opened this issue May 20, 2024 · 1 comment
Closed

Imporve api response schema #146

gaohoward opened this issue May 20, 2024 · 1 comment
Assignees

Comments

@gaohoward
Copy link
Collaborator

Currently the api definitions for most apis uses BrokerRespons as the response type.
It is too general. It should use a more specific type schema for each api.

@lavocatt
Copy link
Collaborator

I will work on this change this week.

lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Define a failure response type in the openapi file and harmonise how the
api-server answers when an failure has to be fired. (e.g always return
the same fields)
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
SimpleResponse was the answer for the login and was used in several
other places. Now there are ApiResponse, DummyResponse and LoginResponse
instead that are used throughout the openapi definition.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Transform the BrokersResponse in multiple types in the openapi
definition:
- Broker
- Acceptor
- Address
- Queue

Updates the unit tests accordingly.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
ComponentDetails is the new type used to type all the details endpoints.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
The component ComponentAttribute types in depth the data return by the
two readXXAttributes endpoints.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Add the missing two readAttributes from the queues and acceptors
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Add a new set of demo components for jolokia to fetch attributes from
the backend.
The dev can now test fetching attributes from the broker, the queues,
the acceptors and the addresses.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Instead of taking a string as the signature of the operation take an
OperationRef object that is easier to use on frontend side.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 22, 2024
Add a new component to allow the user to execute any broker operations.
Each operation has its own form with a sub form per signature of the
function and an execute button.
When the user clicks on execute the request gets ran by the jolokia
endpoint.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 23, 2024
Add a new ExecResult type to correctly type the execution result. This
type could be use for other execXXXOperation in the future.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
Turn on the openapi validator for the response of the api-server to make
sure it is in sync with the openapi definition.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
Bring in fully qualified types for the swagger definition. Before
Generic types were used.

These had for main drawback to prevent us to generate proper types with
the codegen to handle data returned by the api-server. The data was
there but not named. So code like
`OperationResult.Op.listSessions[0].args` wasn't possible. We would have
needed to rely on json parsing. In turns meaning custom parsing code
here and there with a higher bug exposure. Now that we have fully
qualified names, we can rely on the generated typescript types to know
what is inside the data we get back from the server.

The api-server now needs to perform a few transformations to the data
from jolokia in order to be compliant with the return spec. In an ideal
world, the spec should have just needed to follow the jolokia output.
But some roadblock forced us to consider transforming the data in some
ways:
* Strings like `org.apache.activemq.artemis:broker="amq-broker` are
  transformed to a json counterpart:
  ```
  broker: {
      name: `amq-broker`
  }
  ```
* Operations, can be either an object or an array of objects in the
  jolokia response. The api-server transforms these into array of
  objects. This is necessary because there's a bug in the way the
  express-openapi-validator handles the `oneOf` property in the openapi
  definition.
To follow this change of behavior from the api-server, the tests needed
to be updated.

Last but not least, the api-server validates the output json against the
openapi definition too. So we're guaranteed that the result matches what
we expect it to be.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
Using the new typescrit types it gets possible to create dynamic forms
from the ComponentDetails. These forms can be uses to query data for the
addresses, acceptors and queues but also execute broker operations.

These demo component will be helpful to discover what are the accessible
values one can query and what are the available operations one can
execute.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
Bring in fully qualified types for the swagger definition. Before
Generic types were used.

These had for main drawback to prevent us to generate proper types with
the codegen to handle data returned by the api-server. The data was
there but not named. So code like
`OperationResult.Op.listSessions[0].args` wasn't possible. We would have
needed to rely on json parsing. In turns meaning custom parsing code
here and there with a higher bug exposure. Now that we have fully
qualified names, we can rely on the generated typescript types to know
what is inside the data we get back from the server.

The api-server now needs to perform a few transformations to the data
from jolokia in order to be compliant with the return spec. In an ideal
world, the spec should have just needed to follow the jolokia output.
But some roadblock forced us to consider transforming the data in some
ways:
* Strings like `org.apache.activemq.artemis:broker="amq-broker` are
  transformed to a json counterpart:
  ```
  broker: {
      name: `amq-broker`
  }
  ```
* Operations, can be either an object or an array of objects in the
  jolokia response. The api-server transforms these into array of
  objects. This is necessary because there's a bug in the way the
  express-openapi-validator handles the `oneOf` property in the openapi
  definition.
To follow this change of behavior from the api-server, the tests needed
to be updated.

Last but not least, the api-server validates the output json against the
openapi definition too. So we're guaranteed that the result matches what
we expect it to be.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 27, 2024
Using the new typescrit types it gets possible to create dynamic forms
from the ComponentDetails. These forms can be uses to query data for the
addresses, acceptors and queues but also execute broker operations.

These demo component will be helpful to discover what are the accessible
values one can query and what are the available operations one can
execute.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 29, 2024
Bring in fully qualified types for the swagger definition. Before
Generic types were used.

These had for main drawback to prevent us to generate proper types with
the codegen to handle data returned by the api-server. The data was
there but not named. So code like
`OperationResult.Op.listSessions[0].args` wasn't possible. We would have
needed to rely on json parsing. In turns meaning custom parsing code
here and there with a higher bug exposure. Now that we have fully
qualified names, we can rely on the generated typescript types to know
what is inside the data we get back from the server.

The api-server now needs to perform a few transformations to the data
from jolokia in order to be compliant with the return spec. In an ideal
world, the spec should have just needed to follow the jolokia output.
But some roadblock forced us to consider transforming the data in some
ways:
* Strings like `org.apache.activemq.artemis:broker="amq-broker` are
  transformed to a json counterpart:
  ```
  broker: {
      name: `amq-broker`
  }
  ```
* Operations, can be either an object or an array of objects in the
  jolokia response. The api-server transforms these into array of
  objects. This is necessary because there's a bug in the way the
  express-openapi-validator handles the `oneOf` property in the openapi
  definition.
To follow this change of behavior from the api-server, the tests needed
to be updated.

Last but not least, the api-server validates the output json against the
openapi definition too. So we're guaranteed that the result matches what
we expect it to be.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 29, 2024
Using the new typescrit types it gets possible to create dynamic forms
from the ComponentDetails. These forms can be uses to query data for the
addresses, acceptors and queues but also execute broker operations.

These demo component will be helpful to discover what are the accessible
values one can query and what are the available operations one can
execute.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 29, 2024
Bring in fully qualified types for the swagger definition. Before
Generic types were used.

These had for main drawback to prevent us to generate proper types with
the codegen to handle data returned by the api-server. The data was
there but not named. So code like
`OperationResult.Op.listSessions[0].args` wasn't possible. We would have
needed to rely on json parsing. In turns meaning custom parsing code
here and there with a higher bug exposure. Now that we have fully
qualified names, we can rely on the generated typescript types to know
what is inside the data we get back from the server.

The api-server now needs to perform a few transformations to the data
from jolokia in order to be compliant with the return spec. In an ideal
world, the spec should have just needed to follow the jolokia output.
But some roadblock forced us to consider transforming the data in some
ways:
* Strings like `org.apache.activemq.artemis:broker="amq-broker` are
  transformed to a json counterpart:
  ```
  broker: {
      name: `amq-broker`
  }
  ```
* Operations, can be either an object or an array of objects in the
  jolokia response. The api-server transforms these into array of
  objects. This is necessary because there's a bug in the way the
  express-openapi-validator handles the `oneOf` property in the openapi
  definition.
To follow this change of behavior from the api-server, the tests needed
to be updated.

Last but not least, the api-server validates the output json against the
openapi definition too. So we're guaranteed that the result matches what
we expect it to be.
lavocatt added a commit to lavocatt/activemq-artemis-self-provisioning-plugin that referenced this issue May 29, 2024
Using the new typescrit types it gets possible to create dynamic forms
from the ComponentDetails. These forms can be uses to query data for the
addresses, acceptors and queues but also execute broker operations.

These demo component will be helpful to discover what are the accessible
values one can query and what are the available operations one can
execute.
lavocatt added a commit that referenced this issue May 29, 2024
Bring in fully qualified types for the swagger definition. Before
Generic types were used.

These had for main drawback to prevent us to generate proper types with
the codegen to handle data returned by the api-server. The data was
there but not named. So code like
`OperationResult.Op.listSessions[0].args` wasn't possible. We would have
needed to rely on json parsing. In turns meaning custom parsing code
here and there with a higher bug exposure. Now that we have fully
qualified names, we can rely on the generated typescript types to know
what is inside the data we get back from the server.

The api-server now needs to perform a few transformations to the data
from jolokia in order to be compliant with the return spec. In an ideal
world, the spec should have just needed to follow the jolokia output.
But some roadblock forced us to consider transforming the data in some
ways:
* Strings like `org.apache.activemq.artemis:broker="amq-broker` are
  transformed to a json counterpart:
  ```
  broker: {
      name: `amq-broker`
  }
  ```
* Operations, can be either an object or an array of objects in the
  jolokia response. The api-server transforms these into array of
  objects. This is necessary because there's a bug in the way the
  express-openapi-validator handles the `oneOf` property in the openapi
  definition.
To follow this change of behavior from the api-server, the tests needed
to be updated.

Last but not least, the api-server validates the output json against the
openapi definition too. So we're guaranteed that the result matches what
we expect it to be.
lavocatt added a commit that referenced this issue May 29, 2024
Using the new typescrit types it gets possible to create dynamic forms
from the ComponentDetails. These forms can be uses to query data for the
addresses, acceptors and queues but also execute broker operations.

These demo component will be helpful to discover what are the accessible
values one can query and what are the available operations one can
execute.
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

2 participants