Mostly Making oracle easy, mostly:
  • Database News: June edition. 23ai and some LiveSQL
  • Oracle Developer Coaching: May News Edition
  • Build an MCP to connect AI to Oracle Database w/OpenAPI
  • Deploy updates to multiple Oracle Databases, concurrently
  • Getting started with Oracle Database CI/CD & SQLcl Projects
  • SQLcl Projects: Automating Oracle Database app deployments
  • Connecting to Oracle using VS Code & Kerberos Auth
  • How to Export all of your Oracle Database REST APIs
Search for:
  • X (Twitter)
  • YouTube
  • LinkedIn
ThatJeffSmith ThatJeffSmith
  • SQLDev / VS Code
  • SQLDev Web
  • REST APIs
  • Data Modeling
  • Ask A Question
  • About
  • Search for:
In ORDS

Getting the OpenAPI Specs for your ORDS APIs, 2.0 or 3.0!

April 4, 2022 2 Mins Read

When I request the doc describing my endpoints, you have a few choices:

  • metadata-catalog (Specific to ORDS)
  • OpenAPI 2.0
  • OpenAPI 3.0

Metadata Catalog

This was our first entry in cataloging what a schema has available in terms of ORDS REST APIs.

If you pull up

 /ords/{schema}/metadata-catalog

You’ll get a list of modules and REST enabled objects.

I use this endpoint to debug 404’s – does ORDS even KNOW about your endpoint?

There are a couple of links there. The first is just another metadata-catalog endpoint for a specific object or module –

For a table, lists the Primary Key, columns, and data types.

OpenAPI 2.0

But the SECOND link mentioned for items in the metadata-catalog list is for

      "rel": "alternate",
     "href": "http://localhost:8080/ords/hr/open-api-catalog/HTP/",
"mediaType": "application/openapi+json"}

And when we follow THIS –

This is much more interesting AND usable.

“swagger:”: “2.0”…but I want and NEED 3.0!

OpenAPI 3.0

This is currently a ‘trick’ – that is, it’s not documented. I’m having it added to the Docs now. And we’ll probably change the default from Swagger 2.0 to OpenAPI 3.0 later this year…

The Trick is in that Accept header.
curl --request GET \
--url http://localhost:8080/ords/hr/open-api-catalog/autobeers/ \
--header 'Accept: application/vnd.oai.openapi+json;version=3.0'

Swagger, 2.0, 3.0, OpenAPI…I’m confused!

Read this, it will help.

When someone asks for ‘Swagger,’ you might want to ask them, ‘2.0 or 3.0?’

TL;DR – ‘swagger’ = the tools. ‘OpenAPI’ = the specification used to describe REST APIs.

It’s very easy to conflate the YMAL/JSON you see as ‘swagger’ – be careful you’re talking about the same thing when working with others.

metadata-catalogopenapiORDSrestswagger
Author thatjeffsmith

I'm a Distinguished Product Manager at Oracle. My mission is to help you and your company be more efficient with our database tools.

  • Website
Prev Post

Using SQL Developer Web to Test POST Handler REST APIs

April 4, 2022 2 Mins Read
Next Post

Oracle SQLcl 22.1 is now available & featuring Data Guard!

April 6, 2022 3 Mins Read

Related Posts

How to Export all of your Oracle Database REST APIs

April 17, 2025

Secure IOT device uploads to Oracle Database via REST API

March 25, 2025

Pre-Authenticated Requests (PARs) for your Oracle REST APIs

March 7, 2025

6 Comments

  1. Tyler Tarwater 2 years ago Reply

    I’m seeing this error:
    InternalServerException [statusCode=500, logLevel=SEVERE, reasons=[]]
    at oracle.dbtools.rest.metadata.catalog.swagger.SwaggerModelGeneratorBase.handleMetadata(SwaggerModelGeneratorBase.java:189)
    at oracle.dbtools.rest.metadata.catalog.swagger.SwaggerCatalogItemsServlet.doGet(SwaggerCatalogItemsServlet.java:54)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:503)
    at oracle.dbtools.plugin.api.servlet.HttpServletBase.service(HttpServletBase.java:86)
    . . . .
    Caused by: java.sql.SQLException: ORA-61708: Object “RECIPES”.”GET_RECIPES” cannot be described as a JSON schema.
    ORA-06512: at “SYS.DBMS_JSON_SCHEMA”, line 237
    ORA-06512: at “SYS.DBMS_JSON_SCHEMA”, line 280
    ORA-06512: at line 1

    Here is the DDL for that object GET_RECIPES and the table it references:

    CREATE TABLE RECIPES.RECIPES
    (
    RECIPE_NAME VARCHAR2(100 BYTE)
    ) ;

    CREATE OR REPLACE PROCEDURE RECIPES.GET_RECIPES (p_input_txt in varchar2, p_cursor out sys_refcursor) as
    begin
    open p_cursor for
    select * from recipes;
    end;
    /

    p_input_txt isn’t used at the moment, just trying to experiment with ORDS at the moment. Thank you!

    • thatjeffsmith Post Author 2 years ago

      Are you using AUTO plsql feature or did you hand code a module?

    • Tyler Tarwater 2 years ago

      It’s AUTO — and I’ve tried enabling it different ways: from inside APEX, SQL Developer web, SQL developer desktop.

    • Tyler Tarwater 2 years ago

      I was able to get everything to work by manually creating the module. I think for my use case I would ultimately be creating custom modules anyway. Below is the module exported:

      BEGIN
      ORDS.ENABLE_SCHEMA(
      p_enabled => TRUE,
      p_schema => ‘RECIPES’,
      p_url_mapping_type => ‘BASE_PATH’,
      p_url_mapping_pattern => ‘recipes’,
      p_auto_rest_auth => FALSE);

      ORDS.DEFINE_MODULE(
      p_module_name => ‘testmodule’,
      p_base_path => ‘/testmodule/’,
      p_items_per_page => 25,
      p_status => ‘PUBLISHED’,
      p_comments => NULL);

      ORDS.DEFINE_TEMPLATE(
      p_module_name => ‘testmodule’,
      p_pattern => ‘get_recipes’,
      p_priority => 0,
      p_etag_type => ‘HASH’,
      p_etag_query => NULL,
      p_comments => NULL);

      ORDS.DEFINE_HANDLER(
      p_module_name => ‘testmodule’,
      p_pattern => ‘get_recipes’,
      p_method => ‘GET’,
      p_source_type => ‘plsql/block’,
      p_items_per_page => 25,
      p_mimes_allowed => NULL,
      p_comments => NULL,
      p_source =>
      ‘begin
      GET_RECIPES(:txt, :results);
      end;’);

      ORDS.DEFINE_PARAMETER(
      p_module_name => ‘testmodule’,
      p_pattern => ‘get_recipes’,
      p_method => ‘GET’,
      p_name => ‘txt’,
      p_bind_variable_name => ‘txt’,
      p_source_type => ‘HEADER’,
      p_param_type => ‘STRING’,
      p_access_method => ‘IN’,
      p_comments => NULL);

      ORDS.DEFINE_PARAMETER(
      p_module_name => ‘testmodule’,
      p_pattern => ‘get_recipes’,
      p_method => ‘GET’,
      p_name => ‘results’,
      p_bind_variable_name => ‘results’,
      p_source_type => ‘RESPONSE’,
      p_param_type => ‘RESULTSET’,
      p_access_method => ‘OUT’,
      p_comments => NULL);

  2. Tyler Tarwater 2 years ago Reply

    Hi Jeff,
    I can AutoREST enable stored procedures and functions and successfully call them with curl, returning output parameters, but I don’t see these objects show up in the Metadata Catalog. I do see my tables in the Metadata Catalog. Do you expect stored procedures and functions to show up there? Possibly related, I get an error 500 when trying to Export OpenAPI for these types of objects. Thanks!

    • thatjeffsmith Post Author 2 years ago

      On the ords backend log, there should be a ora/plsql error stack from that 500.

      Can you find that, this screams bug.

      Or if you have some plsql to share I can test with here locally.

Write A Comment Cancel Reply

  • Search this site
  • Don’t miss a single post! Enter e-mail to subscribe.
  • Mostly Making Oracle Easy, Mostly

    Privacy Policy 

  • X (Twitter)
  • YouTube
  • LinkedIn
  • Try our new SQL Developer Extension for VS Code
  • Developer Tools Message Boards

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle. © Jeff Smith and ThatJeffSmith, 2025

Top
ThatJeffSmith