You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Noble Paul (Jira)" <ji...@apache.org> on 2019/10/04 03:54:00 UTC

[jira] [Commented] (SOLR-13787) An annotation based system to write v2 only APIs

    [ https://issues.apache.org/jira/browse/SOLR-13787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16944195#comment-16944195 ] 

Noble Paul commented on SOLR-13787:
-----------------------------------

I've changed the annotations a bit. If you do not have a proper json payload  command like the schema API or config API, you do not need a schema. Everything can be done with annotations. In the absence of json schema for a command the introspect may not be able to give out the schema of the payload but everything can work without a schema 

> An annotation based system to write v2 only APIs
> ------------------------------------------------
>
>                 Key: SOLR-13787
>                 URL: https://issues.apache.org/jira/browse/SOLR-13787
>             Project: Solr
>          Issue Type: Task
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Noble Paul
>            Assignee: Noble Paul
>            Priority: Major
>
> example v2 API may look as follows
> {code:java}
> @EndPoint(
>  path = "/api/cluster/package",
>  method = POST,
>  permission = PKG_EDIT
> )
> static class PkgEdit {
>  @Command(name = "add", jsonSchema = "cluster.package.add.json")
>  public void add(CallInfo callInfo) throws Exception {
>  }
>  @Command(name = "update", jsonSchema = "cluster.package.update.json")
>  public void update(CallInfo callInfo) throws Exception {
> }
>  @Command(name = "delete", jsonSchema = "cluster.package.delete.json")
>  boolean deletePackage(CallInfo params) throws Exception {
> }
> {code}
> This expects you to already have the API spec json 
>  
> The annotations are:
>  
> {code:java}
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.TYPE})
> public @interface EndPoint {
> /**The suoported http methods*/
>   SolrRequest.METHOD[] method();
> /**supported paths*/
>   String[] path();
>   PermissionNameProvider.Name permission();
> }
> {code}
> {code:java}
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.METHOD)
> public @interface Command {
>    /**if this is not a json command , leave it empty.
>    * Keep in mind that you cannot have duplicates.
>    * Only one method per name
>    *
>    */
>   String name() default "";
>   String jsonSchema() default "";
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org