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

Ensure correct request / response format #1120

Closed
17 tasks done
heggert opened this issue Nov 4, 2020 · 2 comments
Closed
17 tasks done

Ensure correct request / response format #1120

heggert opened this issue Nov 4, 2020 · 2 comments
Assignees
Labels
API enhancement New feature or request general affects multiple services or domains help wanted Contributions welcome Wice Core Member

Comments

@heggert
Copy link
Member

heggert commented Nov 4, 2020

The REST-API interfaces of the framework services do not always correspond to our standard specifications regarding the request/response format.

1. The request JSON body format for GET / POST / PATCH / PUT / DELETE should not contain the "data" property. Examples that conform to this specification:

Request POST api/service/resource/
body (application/json)

{
	"property1": "1",
	"property2": "abc"
	...
}

Request PATCH api/service/resource/:id
body (application/json)

{
	"property3": "1"
}

2. The response JSON body format must contain at least the "data" property and should contain the "meta" property. Examples that conform to this specification:

Response GET api/service/resource
body (application/json)

{
	"data": [
		{
			"property1": "1",
			"property2": "abc"
		},
		{
			"property1": "2",
			"property2": "abc"
		}
	],
	"meta": {
        	"page": 1,
        	"perPage": 2,
        	"total": 2,
    		"totalPages": 1
	}
}

Response GET api/service/resource/123
body (application/json)

{
	"data": {
		"property1": "123",
		"property2": "abc"
	}
}

All framework services within /services must be examined and, if necessary, adjusted. Communication between the services within the framework must not be impaired.

  • app-directory
  • attachment-storage-service
  • audit-log
  • component-orchestrator
  • component-repository
  • data-hub
  • dispatcher-service
  • flow-repository
  • iam
  • ils
  • meta-data-repository
  • reports-analytics
  • scheduler
  • secret-service
  • snapshots-service
  • template-repository
  • webhooks
@heggert heggert added enhancement New feature or request help wanted Contributions welcome good first issue Good for newcomers general affects multiple services or domains API labels Nov 4, 2020
@heggert heggert changed the title Ensure correct request / response format of our REST-API interfaces Ensure correct request / response format Nov 4, 2020
@heggert heggert removed the good first issue Good for newcomers label Nov 4, 2020
@weberjm
Copy link
Member

weberjm commented Nov 5, 2020

Good description, thanks! The JSON API spec also has some background on the need for the data field, and I think makes for a good review.

I agree with you, though, that the data field is generally not required for the Request object, as you will never make a request with an errors or meta object.

@SvenHoeffler
Copy link
Contributor

After a preliminary examination, it fortunately looks like the majority of services already adhere to the schema. The exceptions I have found so far are as follows:

  • App Directory: Get Response does not contain data/meta
  • Component Repository: Request body requires superfluous data key
  • IAM: Get Responses do not contain data/meta
  • Secret Service: Request bodies requires superfluous data key
  • Webhook Service: Request bodies requires superfluous body key (this is related to Enable passing webhook data into a flow #1201), response body does not have data/meta (less of an issue as webhook service cannot return meaningful data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request general affects multiple services or domains help wanted Contributions welcome Wice Core Member
Development

No branches or pull requests

4 participants