Git Product home page Git Product logo

Comments (3)

padamstx avatar padamstx commented on June 26, 2024

It looks like your custom rule definition is specifying "schemas" for the set of elements to operate on, but the original rule definition specifies "parameters".
Just change the "given" field like this:

given: parameters,

and give that a try.

Edit 1: you'll also need to change the import line at the top.
This line:

const { schemas } = require('@ibm-cloud/openapi-ruleset-utilities/src/collections');

should be changed to:

const { parameters } = require('@ibm-cloud/openapi-ruleset-utilities/src/collections');

Edit 2:
After a closer look, I also realized your definition of "functionOptions" is incorrect for this rule. The configuration specified in the original rule definition is:

    functionOptions: {
      // Allow snake case for query parameter names,
      // but also allow '.' within the name.
      query: {
        type: 'snake',
        separator: {
          char: '.',
        },
      },

      // Allow snake case for path parameter names.
      path: {
        type: 'snake',
      },

      // Allow header parameter names to be in canonical header name form (e.g. X-My-Header).
      header: {
        type: 'pascal',
        separator: {
          char: '-',
        },
      },
    },

So, you'll need to specify an object like this within your custom rule definition. If you want to enforce camel-case only for query params along with snake-case for path params and pascal case for header params, the configuration object would look like this:

    functionOptions: {
      // Allow camel case for query parameter names.
      query: {
        type: 'camel',
      },

      // Allow snake case for path parameter names.
      path: {
        type: 'snake',
      },

      // Allow header parameter names to be in canonical header name form (e.g. X-My-Header).
      header: {
        type: 'pascal',
        separator: {
          char: '-',
        },
      },
    },

from openapi-validator.

padamstx avatar padamstx commented on June 26, 2024

Here is the reference documentation for this rule:
https://github.com/IBM/openapi-validator/blob/main/docs/ibm-cloud-rules.md#ibm-parameter-casing-convention

from openapi-validator.

padamstx avatar padamstx commented on June 26, 2024

Closing this out as the solution has been provided. Please re-open if you encounter other issues.

from openapi-validator.

Related Issues (20)

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.