Git Product home page Git Product logo

wpapi-swaggergenerator's People

Contributors

jmusal avatar lewiscowles1986 avatar okhoshi avatar starfishmod 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

Watchers

 avatar  avatar  avatar

wpapi-swaggergenerator's Issues

target a reference

Hi, your plugin is amazing.
Just a question.. There is a way to relate an object to an already defined definition?

Example:

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'event',
'type' => 'object',
'properties' => array(...)
);

$other_schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'something_needing_an_array_of_events',
'type' => 'object',
'properties' => array(
'listing' => array(
'description' => __( 'listing of events.' )
'type' => 'array',
'items' => array(
// something like:
//'type' => 'event',
//'$ref' => '#/definitions/event'
),
)
)
);

Thanks in advance

Permalink leads to a 404

example.com/index.php/apigenerate/swagger
translates to
example.com/apigenerate/swagger
and then 404s.

Attempted to generate the file on a single site install, and multisite. Same issue on both.

Custom Routes

Is there a way of implementing SwaggerGenerator with custom registered routes. I tried defining a schema but couldn't get it working ..

Could you provide me with an example?

Empty enums

After Wordpress 4.7 upgrade empty enums appeared into template POST parameters in several enpoints (Page, Post):

e.g.:

{  
  "name":"template",
  "type":"string",
  "in":"formData",
  "description":"Teematiedosto joka n\u00e4ytt\u00e4\u00e4 kohteen.",
  "enum":[
    ""
  ]
}

Handle Multi-site

Currently I don't think it handles multi-site well and needs to be fixed. see #3 for a reference to this

Consider integration tests for your WP REST API endpoints

Hi!

On behalf of Pantheon, I'm writing a tutorial on why integration tests are critical for your WP REST API endpoints, and how you can go about writing them.

Given your use of register_rest_field(), I think you could benefit from reading and applying the tutorial. And, because the tutorial isn't yet published, I'd very much appreciate any constructive criticism you have, so that we can make the tutorial an evergreen resource for the community.

Thanks in advance for your time. Happy to take any questions, comments, etc. you might have in this Github issue, or on the document itself (you'll need to be signed into Dropbox).

Submit to WordPress Plugin Directory

It'd be great if this could be submitted to the plugin directory. Earlier on the make WordPress chat someone asked for this exact functionality. I'd be happy to submit (with you as the author) if you let me know your username on wordpress.org

enums in date-time fields

Generated JSON contains enums in date-time properties in definitions section (which causes client generations to fail).

E.g. generated attachment:

definitions:
  attachment:
    type: object
    properties:
      date:
        description: 'The date the object was published, in the site''s timezone.'
        type: string
        format: date-time
        enum:
          - view
          - edit
          - embed

swagger.json does not pass JSON Schema Validator

Loaded plugin, and ran the generator to output swagger.json
goto JSON Schema Validator , select schema Swagger API 2.0
cut/paste swagger.json from WP.

many failures:

  • first operation names of all caps GET, POST, ... should be changed to lower-case as per schema.
  • too many problems to list

NOTE: same validation works fine against petstore swagger.json

Swagger schema: OpenAPI-Specification/schemas/v2.0/schema.json

Swagger-Editor and Swagger-Validator did not like it either.

Can you push and example of the swagger.json you are generating to this repo?
Please include a list of plugins your are using and versions.

I have some time to help in testing with external tools, unfortunately I don't know php.

I also used Convert JSON to YAML Online to create yaml from the swagger.json file.

Setup: Ubuntu Host, Docker WP/MySQL, Docker SwaggerUI

Doesn't report API Endpoint

So I'm making a repo to show how-to author basic REST API endpoints, and I'd like to have a swagger file for that. For some reason this plugin is not working for me. (Checked the plugin btw it works for me)

plugins/{plugin}/index.php

<?php
/*
Plugin Name: CODESIGN2 WordPress REST API Example Plugin
Plugin URI: https://www.codesign2.co.uk
Description: Really basic WordPress REST API Example Plugin
Version: 1.0.0
Author: CD2Team
Author URI: https://www.codesign2.co.uk
*/

add_action('rest_api_init', function(){
    foreach([
        'Test'
    ] as $endpoint) {
        require_once( __DIR__."/controllers/{$endpoint}Controller.php");
        $controller_class = "{$endpoint}Controller";
        $controller = new $controller_class();
        $controller->register_routes();
    }
});

plugins/{plugin}/controllers/TestController.php

<?php

use WP_REST_Server;
use WP_REST_Controller;
use WP_REST_Request;
use WP_REST_Response;

class TestController extends WP_REST_Controller {

    public function __construct() {
        $this->namespace = 'test/v1';
    }

    public function register_routes() {
        register_rest_route(
            "{$this->namespace}",
            "/date",
            [
                [
                    'methods' => WP_REST_Server::READABLE,
                    'callback' => [$this, 'index'],
                    'permission_callback' => [$this, 'index_permissions_check'],
                    'args' => [],
                ]
            ]
        );
    }

    public function index(WP_REST_Request $request) {
        $data = date('Y-m-d H:i:s');
        return new WP_REST_Response( $data, 200);
    }

    public function index_permissions_check(WP_REST_Request $request) {
        return true;
    }
}

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.