GithubHelp home page GithubHelp logo

Comments (8)

JamesMessinger avatar JamesMessinger commented on August 15, 2024 1

This would be a killer feature for us. We want to use openapi-cli as a linter that enforces a consistent folder/file structure in all of our APIs, so any developer in the company can easily work on any API in the company without having to learn a new structure each time. Here's the structure that we're enforcing:

|-- openapi.yaml      (the main/entry file)
|-- info.yaml         (the info section)
|-- tags.yaml         (the tags section)
|-- paths/
| |-- foo/
|   |-- bar/
|     |-- path.yaml   (the definition of the /foo/bar path)
|     |-- get.yaml    (the definition of the GET /foo/bar operation)
|     |-- post.yaml   (the definition of the POST /foo/bar operation)
|
|-- schemas/
  |-- enums.yaml      (all enumerations are defined here)
  |-- fizz.yaml       (the JSON schema for fizz objects)
  |-- buzz.yaml       (the JSON schema for buzz objects)

So we need to be able to create file-level rules such as:

  • The main entry file of the API definition must be named openapi.yaml
  • info.yaml must exist and must contain the API's info section
  • tags.yaml must exist and must contain the list of tags
  • Every path in the API must have a corresponding paths/xxx/yyy/path.yaml file
  • Every operation in the API must have a corresponding paths/xxx/yyy/VERB.yaml file
  • Every object schema must be defined in a corresponding schemas/xxx.yaml file
  • All enumerations must be in enums.yaml
  • The enumerations in enums.yaml must be in alphabetical order

from redocly-cli.

RomanHotsiy avatar RomanHotsiy commented on August 15, 2024

Oh, that's an interesting idea. We're not sure how to fit into our internal concept.

We will discuss it internally and get back to you soon.

from redocly-cli.

adamaltman avatar adamaltman commented on August 15, 2024

@JamesMessinger what are you doing in the case of path parameters with your paths folder structure? For example:

  • foo/get.yaml <-- gets a collection of foos
  • foo/{id}/get.yaml <-- gets a foo with a specific {id}

from redocly-cli.

JamesMessinger avatar JamesMessinger commented on August 15, 2024

Yes, exactly. Path parameters are just part of the folder structure.

from redocly-cli.

adamaltman avatar adamaltman commented on August 15, 2024

This is done (I think). @RomanHotsiy we should add an example of enforcing file names. For example, Rebilly uses PascalCase for component file names with two exceptions: headers (some hybrid of kebab-case and PascalCase == Kebab-Case) and parameters (camelCase). How about a sample rule that enforces a particular case for filenames.

from redocly-cli.

adamaltman avatar adamaltman commented on August 15, 2024

@RomanHotsiy this is effectively done with the $ref assertion, right?

from redocly-cli.

RomanHotsiy avatar RomanHotsiy commented on August 15, 2024

Not exactly but it can be used for some file-names checks for sure.

from redocly-cli.

adamaltman avatar adamaltman commented on August 15, 2024

I'm going to close this since it can be used for $ref filename checks. I'm not sure what other filename would want to be checked besides the root file?

from redocly-cli.

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.