GithubHelp home page GithubHelp logo

tangcent / easy-api Goto Github PK

View Code? Open in Web Editor NEW
161.0 161.0 29.0 24.68 MB

Generate API document

Home Page: https://easyapi.itangcent.com

License: GNU Affero General Public License v3.0

Kotlin 92.17% Shell 0.26% HTML 0.09% Java 7.48%
idea-plugin postman

easy-api's People

Contributors

echo-layker avatar github-actions[bot] avatar tangcent avatar zjz6b6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

easy-api's Issues

support {@link ...} in param desc doc

support {@link ...} in param desc doc like:

    /**
     * some api
     *
     * @param path path_desc {@link com.itangcent.Paths}
     */
    @ResponseBody
    @RequestMapping(value = "/some/{path}", method = RequestMethod.POST)
    public Result method(@PathVariable("path") String path) {
        ...
    }

class Paths:

class Paths{

private final static PATH1 = "path1";//first path
private final static PATH2 = "path2";//second path

}

expect output doc:


path

name desc
path path_desc
path1:first path
path2:second path

Support groovy extension

Support for extending plug-ins with native groovy files

  • Declare the files need to be loaded for which action in the config file
  • The groovy files will be loaded before a action be performed at runtime

So that developers can use groovy scripts in their local project to implement the highly customized actions to satisfy the special needs of their business, and it is free and safe to upgrade the plugin and get the features of the plugin upgrades.
see tangcent/easy-yapi#27

Support switch project api mode

  • original
project api postman▽
moduleA CollectionA
  |─classA CollectionB
    |─apiA CollectionC
    |─apiB ...
  |─classB ...
  • legible
project api postman▽
moduleA CollectionA
  |─attr of classA CollectionB
    |─attr of apiA CollectionC
    |─attr of apiB ...
  |─attr of classB ...

any plan to support eclipse plugin?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

enhanced expression for configuration

old

  • # indicates read from comment tag
  • @ indicates read from annotation
    • @xxx means getting the value from the XXX annotation of a method or field
    • The @xxx#yyy representation gets the value from the yyy attribute of the XXX annotation of a method or field

new

  • support js expression

  • support context:it

  • support method in it:

    • it.annotation("annotation_name"):String?
    • it.annotation("annotation_name#value"):String?
    • it.doc():String
    • it.doc("$tag"):String?
    • it.doc("param.$param"):String?
  • if it is class

    • it.methods:method[]
    • it.name:String
    • it.isExtend(""):Boolean
    • it.isSuper(""):Boolean
    • it.isMap():Boolean
    • it.isList():Boolean
    • it.isArray():Boolean
  • if it is method

    • it.name:String
    • it.return:class
    • it.args:arg[]
  • if it is arg

    • it.name:String
    • it.type:class

Support PopupMenu for Postman Tree

Adding a popup menu to the postman tree

support actions:

  • delete collection/api
  • new sub collection
  • rename collection
  • sync selected collection from postman

ConcurrentModificationException

Receiving this error when attempting to export an api in a directory (code -> export Postman)

IntelliJ 2019.2 Ultimate, JDK 11.

[ERROR] error to parse body
[TRACE] java.util.ConcurrentModificationException
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
at com.itangcent.intellij.psi.DuckTypeHelper.resolve(DuckTypeHelper.kt:91)
at com.itangcent.intellij.psi.DuckTypeHelper.resolve(DuckTypeHelper.kt:78)
at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:175)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.parseResponseBody(SpringClassExporter.kt:604)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.processResponse(SpringClassExporter.kt:173)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.exportMethodApi(SpringClassExporter.kt:155)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.access$exportMethodApi(SpringClassExporter.kt:33)
at com.itangcent.idea.plugin.api.export.SpringClassExporter$export$1.invoke(SpringClassExporter.kt:92)
at com.itangcent.idea.plugin.api.export.SpringClassExporter$export$1.invoke(SpringClassExporter.kt:33)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.foreachMethod(SpringClassExporter.kt:671)
at com.itangcent.idea.plugin.api.export.SpringClassExporter.export(SpringClassExporter.kt:91)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1$2.invoke(CachedClassExporter.kt:114)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1$2.invoke(CachedClassExporter.kt:23)
at com.itangcent.intellij.context.ActionContext$runInReadUI$1.run(ActionContext.kt:293)
at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:53)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:936)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
at com.itangcent.intellij.context.ActionContext.runInReadUI(ActionContext.kt:290)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1.invoke(CachedClassExporter.kt:112)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1.invoke(CachedClassExporter.kt:23)
at com.itangcent.intellij.context.ActionContext$runAsync$2.run(ActionContext.kt:169)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

Refactor Settings of EasyAPI

  • Move Settings to [Preferences -> OtherSettings -> EasyApi]
  • Optimize Token(Postman/Others) setting
  • Multiple tokens supported

Consider the possibility of support for WebFlux Framwork

TODO LIST

  • Spring WebFlux Demo
  • Spring WebFlux + Kotlin Demo
  • Support export Spring WebFlux
  • Support export Spring WebFlux + Kotlin

WebFlux Framwork

Request and Response Body Conversion

For example the request body can be one of the following way and it will be decoded automatically in both the annotation and the functional programming models:

Account account — the account is deserialized without blocking before the controller is invoked.

  • Mono<Account> account — the controller can use the Mono to declare logic to be executed - after the account is deserialized.

  • Single<Account> account — same as with Mono but using RxJava

  • Flux<Account> accounts — input streaming scenario.

  • Observable<Account> accounts — input streaming with RxJava.
    The response body can be one of the following:

  • Mono<Account> — serialize without blocking the given Account when the Mono completes.

  • Single<Account> — same but using RxJava.

  • Flux<Account> — streaming scenario, possibly SSE depending on the requested content type.

  • Observable<Account> — same but using RxJava Observable type.

  • Flowable<Account> — same but using RxJava 2 Flowable type.

  • Flux<ServerSentEvent> — SSE streaming.

  • Mono<Void> — request handling completes when the Mono completes.

  • Account — serialize without blocking the given Account; implies a synchronous, non-blocking controller method.

  • void — specific to the annotation-based programming model, request handling completes when the method returns; implies a synchronous, non-blocking controller method.

When using stream types like Flux or Observable, the media type specified in the request/response or at mapping/routing level is used to determine how the data should be serialized and flushed. For example a REST endpoint that returns a Flux will be serialized by default as following:

  • application/json: a Flux<User> is handled as an asynchronous collection and serialized as a JSON array with an explicit flush when the complete event is emitted.
  • application/stream+json: a Flux<User> will be handled as a stream of User elements serialized as individual JSON object separated by new lines and explicitly flushed after each element. The WebClient supports JSON stream decoding so this is a good use case for server to server use case.
  • text/event-stream: a Flux<User> or Flux<ServerSentEvent> will be handled as a stream of User or ServerSentEvent elements serialized as individual SSE elements using by default JSON for data encoding and explicit flush after each element. This is well suited for exposing a stream to browser clients. WebClient supports reading SSE streams as well.

be

Describe the bug
com.intellij.diagnostic.PluginException: action with the ID "com.itangcent.idea.easy_api.actions.PostmanExportAction" was already registered. Action being registered is ExportPostman (Export Postman); Registered action is Export Postman (Export Postman) Plugin: EasyApi [Plugin: com.itangcent.idea.plugin.easy-api]

To Reproduce
Steps to reproduce the behavior:

  1. Open Idea
  2. Open a spring-mybatis project

Expected behavior
No issue should be displayed.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Win10]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

support .apiignore

rule

desc rule example status
A blank line matches no files, so it can serve as a separator for readability.
A line starting with # serves as a comment. #comment #exclude all api in directory foo/bar
ignore all api in dir dir/ foo/
ignore api by file and api method name ignore_file#method_name foo/Foo#method
ignore api by file and api method name and args ignore_file#method_name(args...) foo/Foo#method(arg1)
ignore api by httpMethod and url :METHOD:path :GET:/foo/a/b
::/foo/a/b

Automatically merge collections of the same name

see #19

Dashboard:

project api postman▽
root CollectionA
  |─moduleA CollectionB
    |─apiA CollectionC
    |─apiB moduleA
  |─moduleB     |─apiA
  • when the a module be imported again,Automatically merge it form project to the same name collection in postman
  • For example, now drag moduleA to postman, only apiB is imported into postman

Api Dashboard

Dashboard:

project api postman▽
root CollectionA
  |─moduleA CollectionB
    |─apiA CollectionC
    |─apiB ...
  |─moduleB ...

Action:

  • load async
  • drag api from project api panel to postman collection

The int property in response displayed as float

Describe the bug

  • The response of API is displayed as {code:0} when it is first loaded.
  • Displayed as {code:0.0} when the API is loaded for the second time

Expected behavior

  • Displayed as {code:0} when the API is loaded for the any time

Support Serializer for Enum

  • Let’s define the following Enum:
    public enum Distance {

        KILOMETER("km", 1000),

        MILE("miles", 1609.34),

        METER("meters", 1),

        INCH("inches", 0.0254),

        CENTIMETER("cm", 0.01),

        MILLIMETER("mm", 0.001);
        private String unit;
        private final double meters;

        private Distance(String unit, double meters) {
            this.unit = unit;
            this.meters = meters;
        }

        public String getUnit() {
            return unit;
        }

        public double getMeters() {
            return meters;
        }
    }
  • 1.Default Enum Representation
    By default, EasyApi will represent Java Enums as simple String – for example:
private Distance distance;

Will be equivalent to

    /**
     * @see Distance
     */
    private String distance;
  • 2.Support Custom Rules
  • 2.1.Convert Enum as special field - for example:
json.rule.enum.convert[your enum class]=your enum class#value field

abbreviated:

json.rule.enum.convert[your enum class]=#value field
  • 2.2.Convert Enum as special method(always getter) - for example:
json.rule.enum.convert[your enum class]=your enum class#method

abbreviated:

json.rule.enum.convert[your enum class]=~#method
  • 2.3.Support use script as filter - for example:
json.rule.enum.convert[groovy:it.extend("com.itangcent.Describable")]=~#desc

see jackson-serialize-enums


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.