Giter Club home page Giter Club logo

Comments (2)

mikekistler avatar mikekistler commented on June 28, 2024

You have linked to the "old" Microsoft API Guidelines, but Azure has published updated API Guidelines here and this style guide and ruleset are a companion to these updated guidelines.

As for your specific concern:

my understanding is that all these properties must be marked as "readOnly", since they are only ever used in responses

OpenAPI v2 describes readOnly this way:

Relevant only for Schema "properties" definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request. Properties marked as readOnly being true SHOULD NOT be in the required list of the defined schema. Default value is false.

So by the specification you are correct that a required property should not be marked readOnly.

But the specification does not require that a schema that is only used for responses mark all its properties as readOnly. And while it seems harmless to do so, it prevents the use of required in response schemas, which is a useful tool in documenting which properties will always be present in a response. So I think that marking properties of a schema that is only used in a response as readOnly is an anti-pattern and should be discouraged.

In fact, the OpenAPI committee recognized the problems with the definition of readOnly in OpenAPI v2 and changed in in OpenAPI v3 to say:

If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only.

So in OpenAPI v3, there is no conflict between readOnly and required.

from azure-api-style-guide.

mikekistler avatar mikekistler commented on June 28, 2024

I think this issue is addressed but please reopen if there is something specific you believe is still needed.

from azure-api-style-guide.

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.