Improved API for Sifu specification language

As said in our what’s next post new API Sifu specification language will be much simpler to learn and use. At the same time, it will enable even give the user, even more, usability and flexibility from the specifications them self.

Here is an example of the user API specification written in new API improvements in the specification language.

UserApi api[secured ADMIN, rest /users](

  nonAdmins read[select from User where User.role != ADMIN,
    response UserResponseDTO, rest /non-admins]

  adminUsers read[query User.adminUsers,
    rest /admins, response UserResponseDTO]

  activeUsers read[select from User where == true,
    rest /active, response UserResponseDTO, paged]

  UserResponseDTO dto[model User](

  UserActivationDTO dto[model User](
    userIds list [default false]

  setUserActiveStatus update[select from User where in userIds,
    request UserActivationDTO, response list UserResponseDTO, rest /active]

  UserActivationSimpleDTO dto[model User](

  setUserActiveStatusSimple update[request list UserActivationSimpleDTO,
    response list UserResponseDTO, rest /active/simple]

Now the endpoints can be defined with keywords: crud, create, read, update and delete. We’ve stripped down the crud to be as simple as possible and allow the user to expose the whole model in just one line:

specialties crud[model VetSpeciality, rest /vet/specialties]

For more advanced endpoints you can use create, read, update and delete keywords. To define the request and response format you should either predefine a DTO or define it inline.

Here is an example of the specification of create endpoint with predefined DTO’s:

VetResponseDTO dto[model Vet](

CreateVetDTO dto[model Vet](
  password text[min 1, max 40]
  Vet.specialities dto[model VetSpeciality](

createVet create[request CreateVetDTO, response VetResponseDTO, rest /vet]

Here is an example of a specification of the read endpoint with inline definition of response DTO:

findOwners read[select from Owner orderable by Owner.lastName,, response dto(, Owner.firstName, Owner.lastName), rest /owners]

We’ll release a far more detailed tutorial in the coming weeks. Regard this post just as a sneak preview.

Keep building.